WEB开发网
开发学院软件开发Java SSH笔记四 整合struts2 阅读

SSH笔记四 整合struts2

 2009-09-23 00:00:00 来源:WEB开发网   
核心提示: 2. 配置web.xml,添加struts2的过滤器<!DOCTYPEweb-appPUBLIC"-//SunMicrosystems,Inc.//DTDWebApplication2.3//EN""http://java.sun.com/dtd/web-ap

2.  配置web.xml,添加struts2的过滤器

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/classes/application-context.xml</param-value>
 </context-param>
  <!--struts过滤器 -->
 <filter>
  <filter-name>struts2</filter-name>
  <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
 </filter>
 <filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>*.action</url-pattern>
 </filter-mapping>
 <!-- 加载spring配置文件 -->
 <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 </listener>
 <!-- 设置欢迎页 -->
 <welcome-file-list>
  <welcome-file>login.jsp</welcome-file>
 </welcome-file-list>
</web-app>

3.  添加struts.xml配置文件

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="false" />
    <constant name="struts.objectFactory" value="spring" />
    
    <include file="struts/user.xml"></include>
       
</struts>

上一页  1 2 3 4 5  下一页

Tags:SSH 笔记 整合

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接