我在Maven,Struts 2中有一个正在运行的项目,我正在尝试添加struts2-junit-plugin进行测试。
因此,我添加了插件的支柱,2-junit。
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-junit-plugin</artifactId>
<version>2.3.20</version>
</dependency>运行之后,我得到了以下错误:
java.lang.NoClassDefFoundError: javax/servlet/jsp/PageContext然后,我为jsp-api添加了插件。
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
<scope>prototype</scope>
</dependency>当我运行它时,我得到了一个不同的错误:
java.io.FileNotFoundException: class path resource [WEB-INF/content/] cannot be resolved to URL because it does not exist我试图对我的struts.xml做以下更改
<constant name="struts.convention.result.path" value="/src/main/webapp/WEB-INF"但它也不起作用。
当我从pom文件中删除struts2-convention-plugin时,它可以工作。
但我需要2-常规插件。有人能说出这里有什么问题吗?
发布于 2015-10-08 15:30:41
我在一位朋友的帮助下得到了解决方案,我没有在struts.xml中使用这行struts.xml.
但是我在WEB_INF/content/user-actions内部创建了文件夹结构src/main/resources,它起了作用。
发布于 2015-10-08 09:31:40
您使用了错误的版本和依赖范围。代之以
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>并使用结果路径的默认配置。
<constant name="struts.convention.result.path" value="/WEB-INF/content" />发布于 2018-10-12 03:00:30
我也面临着同样的问题,并通过在struts.xml中添加下面一行来解决
<constant name="struts.convention.result.path" value="/" />
https://stackoverflow.com/questions/33004097
复制相似问题