- 1、本文档共9页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Apache MINA和Spring MVC集成
Apache MINA和Spring MVC集成
1.创建项目
创建一个Spring MVC的WEB应用项目,导入Spring MVC相关的jar包。
另外还需要导入支持Spring面向切面编程的几个包,如下:
aopalliance.jar
aspectjweaver-1.6.12.jar
ognl-3.0.6.jar
两个日志相关的包,如下:
slf4j-api-1.6.6.jar
slf4j-jdk14-1.6.6.jar
另外导入MINA的包,如下:
mina-core-2.0.7.jar
mina-integration-beans-2.0.7.jar
2.配置
1) 配置web.xml
其实就是Spring MVC的相关配置。
?xml version=1.0 encoding=UTF-8?
web-app version=2.5
xmlns=/xml/ns/javaee
xmlns:xsi=/2001/XMLSchema-instance
xsi:schemaLocation=/xml/ns/javaee
/xml/ns/javaee/web-app_2_5.xsd
display-name/display-name
!-- Spring MVC的配置 --
servlet
descriptionSpring MVC的配置/description
servlet-nameSpringMVC/servlet-name
servlet-classorg.springframework.web.servlet.DispatcherServlet/servlet-class
init-param
param-namecontextConfigLocation/param-name
param-valueclasspath:applicationContext.xml,classpath:spring-servlet.xml/param-value
/init-param
load-on-startup1/load-on-startup
/servlet
!-- Spring MVC的映射 --
servlet-mapping
servlet-nameSpringMVC/servlet-name
url-pattern*.htm/url-pattern
/servlet-mapping
welcome-file-list
welcome-fileindex.jsp/welcome-file
/welcome-file-list
/web-app
2) 配置spring-servlet.xml
也是很普通宾配置项。
?xml version=1.0 encoding=UTF-8?
beans xmlns=/schema/beans
xmlns:xsi=/2001/XMLSchema-instance
xmlns:p=/schema/p
xmlns:context=/schema/context
xsi:schemaLocation=/schema/beans
/schema/beans/spring-beans-3.0.xsd
/schema/context
/schema/context/spring-context-3.0.xsd
context:component-scan base-package=com.memo /
bean id=viewResolver class=org.springframework.web.servlet.view.UrlBasedViewResolver
property name=viewClass value=org.springframework.web.servlet.view.JstlView /
property name=prefix value=/ /
property name=suffix value=.jsp /
/bean
/beans
3) 配置applicationContext.xml
这里只保留了MINA需要的几个bean的配置。
?xml version=1.0 encoding=UTF-8?
beans xmlns=/schema/beans
xmlns:aop=/schema/aop xmlns:context=/schema/context
xmlns:p=/schema/p xmlns:tx=/schema/tx
xmlns:xsi=/2001/XMLSchema-insta
您可能关注的文档
- A Knowledge-Navigation System for Dimensional Metrology Volume 107 Number 2 March–April.pdf
- A Layered Approach for Designing Multiple User Interfaces from Task and Domain Models.pdf
- A lower limit on the neutralino mass in the MSSM with non-universal gaugino masses.pdf
- A Low-Carbohydrate as Compared with a Low-Fat Diet in Severe Obesity_540008091.pdf
- A Measurement of the Rate of Charm Production in W Decays.pdf
- A Memory Markov Chain Model For VBR Traffic With Strong Positive Correlations.pdf
- A Morphographemic Model for Error Correction in Nonconcatenative Strings.pdf
- a new 122mm2 electromechanical drill for deep ice-sheet coring 1.design concepts.pdf
- A New Model for Iron Emission Lines and Re-Burst in GRB X-Ray Afterglows.pdf
- A new reverse auction agent system for m-commerce using mobile agents.pdf
文档评论(0)