tiwenzhuanyong 2012-08-31 18:06
浏览 206
已采纳

struts2.3.1版本怎么更改struts.xml的位置?

按照网上说的在web.xml中更改
[code="xml"]

config
struts-default.xml,struts-plugin.xml,../resources/struts2/struts.xml

[/code]
不管用,报错找不到action(struts.xml在src目录下能正常访问)
有没有人实际操作过?

  • 写回答

2条回答 默认 最新

  • iteye_5246 2012-08-31 21:53
    关注

    =============web.xml =============
    [code="xml"]
    <?xml version="1.0" encoding="UTF-8"?>
    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">

    <!-- struts2 -->
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>
            org.apache.struts2.dispatcher.FilterDispatcher
        </filter-class>
        <init-param>
            <param-name>config</param-name>
            <param-value>../struts2conf/struts.xml</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    <welcome-file-list>
        <welcome-file>index.wml</welcome-file>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    


    [/code]
    ===============struts.xml================ 在 struts2conf 目录下
    [code="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">

    <!-- struts2 默认配置文件,必须加进来 有这里看出,当前文件的路径是跟路径下classes路径,所以其他的文件要从classes这个路径开始找 -->


    <!-- 自己添加的配置文件 注意路径 -->



    [/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料