struts2配置文件web.xml常用配置说明

1.struts在2.1.3之前,fiter-class为 <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>,

之后版本为<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>


2.strtus2的标签库文件在struts-core.jar中,tomcat容器会自动找到它,可以不用在web.xml中配置它的位置,如果要统一管理它的位置,可以在web.xml中这样配置

 <taglib>

       <taglib-uri>/s</taglib-uri>  <!--这是jsp页面所要引用的虚拟路径-->

       <taglib-location>/WEB-INF/struts-tags.tld</taglib-location>  <!--tld文件的实际位置-->

 <taglib-uri>/c</taglib-uri>
        < taglib-location >/WEB-INF/c.tld</ taglib-location >

 <taglib-uri>/f</taglib-uri>
        < taglib-location >/WEB-INF/functions.tld</ taglib-location >


    </taglib>

3.ssh整合时,在web.xml配置spring文件位置.

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath*:applicationContext.xml,
            /WEB-INF/customization/*.xml            <!--加载不同模块下的spring bean的配置-->
        </param-value>
    </context-param>
    <!--初始化spring容器-->
    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>

4.配置log4j日志

<context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/classes/log4j.properties</param-value> <!--注意,这里有classes,说明是编译后的文件路径-->
    </context-param>

    <listener>
        <listener-class>
            org.springframework.web.util.Log4jConfigListener
        </listener-class>
    </listener>


5.配置ajax框架dwr

        <servlet>
        <servlet-name>dwr-invoker</servlet-name>
        <servlet-class>
            org.directwebremoting.servlet.DwrServlet
        </servlet-class>

        <init-param>
            <param-name>debug</param-name>
            <param-value>true</param-value>
        </init-param>


        <!-- 设置日志级别 -->
        <init-param>
            <param-name>logLevel</param-name>
            <param-value>WARN</param-value>
        </init-param>


        <!-- 如何允许跨哉请求,则设为false,    默认为true -->
        <init-param>
            <param-name>crossDomainSessionSecurity</param-name>
            <param-value>false</param-value>
        </init-param>

    </servlet>

    <servlet-mapping>
        <servlet-name>dwr-invoker</servlet-name>
        <url-pattern>/dwr/*</url-pattern>
    </servlet-mapping>




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值