加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex + Hessian 学习笔记(三)

发布时间:2020-12-15 04:29:00 所属栏目:百科 来源:网络整理
导读:使用Flex2 + Hessian + Spring 改进一下笔记(二)中的例子。 主要用Spring来替代HessianServlet (其它代码与上例相同,这里就不再重复) web.xml 代码 context-param ?? ???? param-name contextConfigLocation / param-name ?? ???? param-value /WEB-INF/spri

使用Flex2 + Hessian + Spring 改进一下笔记(二)中的例子。
主要用Spring来替代HessianServlet (其它代码与上例相同,这里就不再重复)

web.xml 代码
  1. <context-param>??
  2. ????<param-name>contextConfigLocation</param-name>??
  3. ????<param-value>/WEB-INF/springconfig/*.xml</param-value>??
  4. </context-param>??
  5. ??
  6. <listener>??
  7. ????<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>??
  8. </listener>??
  9. ???<servlet>??
  10. ????<servlet-name>remoting</servlet-name>??
  11. ????<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>??
  12. ???</servlet>??
  13. ??
  14. ???<servlet-mapping>??
  15. ???<servlet-name>remoting</servlet-name>??
  16. ???<url-pattern>/remoting/*</url-pattern>??
  17. </servlet-mapping>??
remoting-servlet.xml 代码
    <beans>??
  1. ??
  2. ????<bean?name="/UserService"?class="org.springframework.remoting.caucho.HessianServiceExporter">??
  3. ????????<property?name="service"?ref="userService"/>??
  4. ????????<property?name="serviceInterface"?value="myhessian.service.UserService"/>??
  5. ????</bean>??
  6. ??? ??
  7. </beans>??
applicationContext-service.xml 代码
    <beans>??
  1. ??
  2. ????<bean?id="userService"?class="myhessian.service.UserServiceImpl">??
  3. ????</bean>??
  4. ???? ??
  5. </beans>??

?java服务端只需添加上面的spring配置即可,这样就不再需要写HessianServlet了.
而在flex的客户端,只需要修改UserService中的服务地址就行了.

UserService.as 代码
    public?class?UserService?extends?BaseService?{ ??
  1. ???? ??
  2. ????private?static?var?_userService?:?HessianService; ??
  3. protected?static?function?getUserService():HessianService?{ ??
  4. ????????if?(!_userService)?{ ??
  5. ????????????_userService?=?new?HessianService("remoting/UserService"); ??
  6. ????????} ??
  7. return?_userService; ??
  8. ????} ??
  9. ???? ??
  10. ????... ??
  11. } ?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读