问题似乎很愚蠢,因为我没有理解这个文件.基本上我只想根据这条指令运行hello-world无动作示例,只需将hello.jsp文件添加到WEB-INF/content中,然后运行localhost:8080/test/hello,但Struts会一直显示异常java.lang. NoSuchMethodException:com.opensymphony.xwork2.ActionSupport.index().
所以我想在运行之前需要完成任何配置.我找不到关于hello-world示例配置的任何事情.
有谁能建议我正确的方法?谢谢
更新:这里是项目树,没有动作,没有任何幻想.
??? pom.xml
??? src
??? main
??? resources
? ??? struts.xml
??? webapp
??? WEB-INF
? ??? content
? ? ??? hello.jsp
? ??? web.xml
??? index.jsp
Run Code Online (Sandbox Code Playgroud)
pom.xml中的依赖项
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.8</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-rest-plugin</artifactId>
<version>2.3.8</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>2.3.8</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-config-browser-plugin</artifactId>
<version>2.3.8</version>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>6.1.26</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
Luk*_*art 10
你已经将Struts 2 Convention插件与Struts 2 REST插件混合在一起,这就是为什么Struts 2正在寻找名为index()的方法(REST的默认方法).
删除REST插件 - struts2-rest-plugin- 一切都应该按预期工作.
如果您想将Convention与REST混合,请参阅文档,例如.您可以使用它struts.rest.namespace来区分应用程序的REST部分和普通的Web应用程序部分.
编辑
如果您想混合使用双方 - 普通的Web应用程序和REST端点 - 您可以考虑使用PrefixBasedActionMapper,它允许每个URL使用不同的映射器.此外,您应该使用PrefixBasedActionProxyFactory适当的工厂来构建与URL匹配的操作.
| 归档时间: |
|
| 查看次数: |
1713 次 |
| 最近记录: |