码迷,mamicode.com
首页 > 其他好文 > 详细

SSH框架搭建准备

时间:2017-06-05 11:39:07      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:ble   webapp   apach   http   ima   dispatch   .com   lte   filter   

1、引入所需要的jar包

技术分享

2、在web.xml文件中配置Struts2 的过滤器和spring 的监听器

<?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"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
	id="WebApp_ID" version="3.0">
	
	<!--spring 核心监听器  -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:applicationContext.xml</param-value>
	</context-param>
	
	<!--struts2 核心过滤器  -->
	<filter>
		<filter-name>strutsFilter</filter-name>
		<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>strutsFilter</filter-name>
		<url-pattern>*.action</url-pattern>
	</filter-mapping>
</web-app>

3、spring配置文件 applicationContext.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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
	http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    
    
</beans>

4、struts的配置文件 struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
	"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
	"http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>
	
	<!-- 设置开发模式(显示错误信息) -->
    <constant name="struts.devMode" value="true" />
	
	<!-- 禁用动态方法访问 -->
    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    
    <!-- 扩展名称为 .action -->
	<constant name="struts.action.extension" value="action" />
	
	 <!--把主题配置城simple -->
    <constant name="struts.ui.theme" value="simple" />
	


</struts>

总结:三个框架的jar包、三个配置文件。

下一篇:测试框架

SSH框架搭建准备

标签:ble   webapp   apach   http   ima   dispatch   .com   lte   filter   

原文地址:http://www.cnblogs.com/py1994/p/6943931.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!