首页 > 代码库 > SSH框架 web.xml配置

SSH框架 web.xml配置

<?xml version="1.0" encoding="UTF-8"?><web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee     http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"><!-- SSH整合后web.xml配置 -->    <!-- web.xml文件中需要配置的信息有: -->    <!-- 1、防止乱码的过滤器 -->    <filter>        <filter-name>charset</filter-name>        <filter-class>        <!-- 处理乱码的类 -->            org.springframework.web.filter.CharacterEncodingFilter        </filter-class>        <init-param>            <param-name>charset</param-name>            <param-value>utf-8</param-value>        </init-param>    </filter>     <!-- 2.配置struts2过滤器 -->      <filter>         <filter-name>Struts2</filter-name>         <filter-class>             org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter         </filter-class>         <!-- 指定action所在的package -->         <init-param>             <param-name>actionPackages</param-name>             <param-value>com.boke.ctl.struts2Action</param-value>         </init-param>     </filter>          <filter-mapping>         <filter-name>Struts2</filter-name>         <url-pattern>/*</url-pattern>         <!-- 疑问点!||| -->         <dispatcher>REQUEST</dispatcher>         <dispatcher>FORWARD</dispatcher>     </filter-mapping>          <!-- 3.配置一个监听器将请求转发给 Spring框架 -->     <listener>         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>     </listener>          <!-- 4.配置一个参数,告诉容器,spring配置文建的位置 -->     <context-param>         <param-name>contextConfigLocation</param-name>         <param-value>classpath:Location</param-value>     </context-param>          <!-- 5.也可以配置一个自定义的Servlet,进行特殊操作 -->     <servlet>            <servlet-name>myServlet</servlet-name>            <servlet-class>org.directwebremoting.servlet.myServlet</servlet-class>        </servlet>     <servlet-mapping>        <servlet-name>myServlet</servlet-name>        <url-pattern>/myServlet/*</url-pattern>     </servlet-mapping>          <!-- 6、配置jsp标签 -->     <jsp-config>        <taglib>            <taglib-uri>/WEB-INF/struts-tags.tld</taglib-uri>            <taglib-location>/WEB-INF/struts-tags.tld</taglib-location>        </taglib>     </jsp-config>          <!-- 7、错误页面 -->     <error-page>        <error-code>404</error-code>        <location>/error.jsp</location>     </error-page>          <!-- 首页,欢迎页面 -->     <welcome-file-list>        <welcome-file>mainB/login.jsp</welcome-file>     </welcome-file-list>          <!-- 9、session登出时间 -->     <session-config>        <session-timeout>30</session-timeout>     </session-config></web-app>

 

SSH框架 web.xml配置