struts2之web.xml常用配置

<?xml version="1.0" encoding="gbk"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<!-- ======================SSHweb.xml配置 ==================-->
<!-- 展示名称,有无一样: -->
<display-name>mySSHAnnotationsTest</display-name>

<!-- 欢迎页面 -->  
<welcome-file-list>
<welcome-file>/login.jsp</welcome-file>
</welcome-file-list>

<!-- 错误页面 -->
    <error-page>
        <error-code>404</error-code>
        <location>/error.jsp</location>
    </error-page>
   
    <!--字符编码 -->
    <filter>
        <filter-name>charset</filter-name> 

        <filter-class>  org.springframework.web.filter.CharacterEncodingFilter  </filter-class>   

<!-- ����������� -->

        <init-param>
            <param-name>charset</param-name>
            <param-value>gbk</param-value>
        </init-param>
    </filter>
    
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener </listener-class>
</listener>  
 
<!-- 负责根据用户提交的URL和struts. xml 中的配置,来选择合适的动作(Action),让这个Action来处理用户请求。 FilterDispatcher 其实是一个过滤器--> 
<filter>
<filter-name>struts2</filter-name>
<filter-class> org.apache.struts2.dispatcher.FilterDispatcher  </filter-class>
<!-- ָ配置扫描的包,action���ڵ�package -->
        <init-param>
             <param-name>actionPackages</param-name>
             <param-value>com.cjg.*</param-value>
        </init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
<!-- 什么意思??->
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
</filter-mapping>

<!--使用自定义Servlet-->
<servlet>
<servlet-name>safecode</servlet-name>
<servlet-class>com.cjg.util.SafeCode</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>safecode</servlet-name>
<url-pattern>/safecode</url-pattern>
</servlet-mapping>

<!--??? ����һ���������������spring�����Ľ���λ��
     <context-param>
         <param-name>contextConfigLocation</param-name>
         <param-value>classpath:Location</param-value>
     </context-param>   -->

<!-- ����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>

<!-- session过期时间 -->
     <session-config>
        <session-timeout>30</session-timeout>
     </session-config>
</web-app>

猜你喜欢

转载自blog.csdn.net/qq_32444825/article/details/80239429