最近在整合spring mvc 和 hessian的时候 ,应该对spring mvc的HandlerMapping 的映射机制不太清楚。。花了老长时间!!最后还是解决了!!在这里把代码给贴出来 大家分享下
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>webapp</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
WEB-INF/osgi-context.xml
WEB-INF/applicationContext.xml
WEB-INF/springMVC-servlet.xml
</param-value>
</context-param>
<context-param>
<param-name>contextClass</param-name>
<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>springMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springMVC</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>hessian-servlet</servlet-name>
<servlet-class>com.artogrid.hessian.servlet.CustomDispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
WEB-INF/hessian-remoting.xml
</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>hessian-servlet</servlet-name>
<url-pattern>/hessian/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
注意:com.artogrid.hessian.servlet.CustomDispatcherServlet 是我自己集成了下DispatcherServlet 应该我想得到 WebApplicationContext这个上下文 为了在使用hessian的时候我可以知道bean的名称我找到具体的bean的事例!!
springMVC-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="com.venusource.app.contact" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<mvc:annotation-driven />
</beans>
hessian-remoting.xml的代码
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="hessian" class="com.artogrid.hessian.service.impl.Hessian"/>
<bean id="httpRequestHandlerAdapter" class="org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter"></bean>
<bean name="/helloHessian"
class="org.springframework.remoting.caucho.HessianServiceExporter">
<property name="service"><ref bean="hessian"/></property>
<property name="serviceInterface">
<value>com.artogrid.hessian.service.IHessian</value>
</property>
</bean>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="order" value="1" />
</bean>
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">
<property name="order" value="2" />
</bean>
</beans>
注意::
<bean id="httpRequestHandlerAdapter" class="org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter"></bean>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="order" value="1" />
</bean>
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">
<property name="order" value="2" />
</bean>
是能否成功的关键
我已经测试过了spring mvc 和 hessian 都是可以使用的!!由于我的工程是OSGI virgo 工程代码不好分享!!
分享到:
相关推荐
**Spring MVC、Hessian与Maven简单实例** 在IT行业中,Spring MVC、Hessian和Maven是三个重要的技术组件,它们分别在Web开发、远程服务调用和项目构建管理方面发挥着关键作用。本篇文章将深入探讨这些技术,并提供...
Spring MVC 和 Hessian 整合是企业级应用中常见的技术组合,主要用于构建分布式服务。Spring MVC 是一个基于模型-视图-控制器(MVC)设计模式的轻量级 web 框架,而 Hessian 是一种高效的远程方法调用(RPC)协议,...
在Hessian整合中,Spring应用上下文将用来注册和管理Hessian服务。 3. **Hessian库**(hessian-4.0.37.jar):这是实现Hessian协议的Java库,提供了创建Hessian服务和客户端的方法。 4. **Spring Web模块**...
在Spring Web Flow项目中应用Hessian服务,是一个深入整合分布式服务和前端流程管理的重要实践。Spring Web Flow(SWF)是一个强大的MVC框架,用于构建具有复杂导航逻辑的Web应用程序,而Hessian则是一种轻量级的二...
在IT行业中,构建高效、可扩展的Web应用是至关重要的,而Spring MVC、Hibernate和Hessian这三大技术框架的整合可以实现这一目标。本篇将详细介绍这三个组件以及它们如何协同工作,帮助开发者构建高质量的分布式应用...
### Spring MVC 与 Dubbo 整合知识点解析 #### 一、Spring MVC 与 Dubbo 概述 ##### 1.1 Spring MVC Spring MVC 是 Spring 框架中的一个模块,它为基于 Java 的 Web 应用程序提供了一个全功能的 MVC 实现。Spring ...
本文主要讨论的是如何将Hessian RPC与RMI技术整合到Structs、Spring、Hibernate和Ibatis这四个关键的Java开发框架中,以构建一个高效、灵活的分布式应用程序。 1. **Hessian配置说明**: Hessian的配置通常涉及...
整合 Dubbo + SpringMvc 4.3.1 的服务器maven工程样例,使用注解方式定义服务及IOC装配,采用Hessian协议传输 三个工程,在 cnetAdmin 和 cnetBlu 中,要引用 cnetCommon 工程。
《Spring与Hessian整合实战详解》 在Java开发领域,Spring框架因其强大的功能和灵活性而备受推崇,而Hessian则是一种轻量级的远程过程调用(RPC)协议,能够实现跨语言的服务调用。本项目"jinrongjuServer"正是一个...
Dubbo 整合 Zookeeper 和 SpringMVC 详细教程 本教程将主要介绍 Dubbo 的基本概念、Dubbo 的架构、Dubbo 与 Zookeeper 的整合、Dubbo 与 SpringMVC 的整合等方面的知识点。 一、Dubbo 基本概念 Dubbo 是一个...
Struts2、MyBatis3和Spring3是Java Web开发中的三大...以上就是Struts2、MyBatis3和Spring3整合的基础知识和在一个Student管理小案例中的具体应用。通过这样的整合,开发者可以构建出功能强大、结构清晰的Web应用程序。
【标题】"dubbox + springmvc 2017整合最新版"涉及的主要知识点是分布式服务框架dubbox与Spring MVC的集成应用。dubbox是阿里巴巴开源的一个基于Java的RPC框架,它在dubbo的基础上增加了更多的特性,如REST支持、...
Spring MVC、Spring Boot和Dubbo是Java开发领域中极为重要的技术框架,它们分别在Web应用、微服务管理和分布式服务调用方面发挥着关键作用。这篇文档将深入探讨这三者的核心概念、工作原理以及如何结合使用。 **...
Spring框架是一个开源的Java平台,它提供了控制反转(Inversion of Control,IoC)容器、面向切面编程(Aspect-Oriented Programming,AOP)功能、声明式事务管理、持久层框架整合、MVC Web框架、测试支持等功能。...
Hibernate 宣告式交易管理 <br> Web 层 Spring 提供了 MVC Web 框架,您可以善用 IoC 容器在依赖注入上的好处,另一方面,Spring 也致力于与其它的 Web 框架的整合。 Spring MVC 入门 从一...
介绍如何在Spring框架中整合其他流行的Web框架,如Struts、JSF等,以及如何在多框架环境中保持代码的一致性和可维护性。 **第11章:安全Spring应用程序** 探讨如何使用Spring Security模块来保护Spring应用程序的...
第17章:介绍了使用Spring进行Web应用程序开发,包括Spring MVC的使用方法和高级特性。 第18章:讲解了Spring Web Flow和JavaServer Faces(JSF)的集成使用,展示了如何构建具有复杂流程的Web应用程序。 第19章:...
2.5.1. Spring MVC的表单标签库 2.5.2. Spring MVC合理的默认值 2.5.3. Portlet 框架 2.6. 其他特性 2.6.1. 动态语言支持 2.6.2. JMX 2.6 .3. 任务规划 2.6.4. 对Java 5(Tiger)的支持 2.7. 移植到Spring 2.0 ...
10. **Chapter 11**:可能讲解了Spring与其他技术的整合,如Spring与Struts、JSF等其他MVC框架的集成,或是Spring与EJB的协同工作。 通过这些章节的源代码,读者不仅可以学习到Spring框架的核心技术和高级特性,还...
1. **完整Spring Web应用**:这种应用通常使用Spring的全套功能,包括事务管理、DI和Web MVC,业务逻辑由POJO实现,通过TransactionProxyFactoryBeans实现事务性,同时Spring的ORM支持可以整合Hibernate、JDO和...