【发布时间】:2011-06-07 02:58:48
【问题描述】:
我在netbeans7.0下使用StrutsTestCase2.4和struts1.3
运行testCase时显示:
Error initializing action servlet
javax.servlet.UnavailableException: The /WEB-INF/web.xml was not found.
这个问题我google了一下,建议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 下。
【问题讨论】:
-
可以通过
new File().getCanonicalPath()找到文件路径。但我不知道你到底是什么意思。