gpt4 book ai didi

testing - StrutsTestCase/WEB-INF/web.xml 没有找到

转载 作者:行者123 更新时间:2023-11-28 20:09:39 25 4
gpt4 key购买 nike

我在netbeans7.0下用StrutsTestCase2.4搭配struts1.3
运行testCase时显示:

Error initializing action servlet
javax.servlet.UnavailableException: The /WEB-INF/web.xml was not found.

我用谷歌搜索了这个问题,建议通过 setContextDirectory(new File("../web")); 解决:

protected void setUp() throws Exception
{
super.setUp();
setContextDirectory(new File("../web"));
}

但我不太确定 new File() 的位置应该是什么。
我的文件树是

|───build
│ ├───test
│ │ └───classes
│ │ └───com
│ │ └───stolon
│ │ ├───common
│ │ ├───database
│ │ ├───helpers
│ │ └───struts
│ └───web
│ ├───META-INF
│ └───WEB-INF
│ ├───classes
│ │ └───com
│ │ └───stolon
│ │ ├───algorithm
│ │ ├───database
│ │ ├───helpers
│ │ ├───servlet
│ │ ├───structures
│ │ └───struts
│ └───lib
├───nbproject
│ └───private
├───src
│ ├───conf
│ └───java
│ └───com
│ └───stolon
│ ├───algorithm
│ ├───database
│ ├───helpers
│ ├───servlet
│ ├───structures
│ └───struts
├───test
│ └───com
│ └───stolon
│ ├───common
│ ├───database
│ ├───helpers
│ └───struts
└───web
├───META-INF
└───WEB-INF

我的测试文件在 test-com-stolon-struts 下。

最佳答案

我刚遇到这个。当测试运行时,WEB-INF/web.xml(可能还有 struts-config.xml 等)必须在您的类路径中。确保 netbeans 将/build/web/放在测试类路径中。

如果您使用的是 Maven,您将添加 WEB-INF/*.xml 作为测试资源。

    <testResources>
<testResource>
<directory>WEB-INF</directory>
<targetPath>/WEB-INF</targetPath>
<includes>
<include>*.xml</include>
</includes>
</testResource>
</testResources>

关于testing - StrutsTestCase/WEB-INF/web.xml 没有找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6260218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com