这个问题似乎很愚蠢,因为我完全误解了这份文件。基本上,我只想根据这个WEB-INF/content运行hello-world无动作示例,只需将hello.jsp文件添加到说明中,然后运行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.jsppom.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>发布于 2013-02-12 07:50:16
您已经将Struts 2约定插件与Struts 2 REST插件混合在一起,这就是Struts 2寻找名为index() (REST的默认方法)的方法的原因。
删除REST插件-- struts2-rest-plugin --一切都应该像预期的那样工作。
如果你想把会议和休息混为一谈,请咨询医生。您可以使用struts.rest.namespace区分应用程序的REST部分和正常的web应用程序部分。
编辑
如果你想混合双方-一个正常的网络应用程序和REST端点-你可以考虑使用PrefixBasedActionMapper,它允许使用不同的映射器每个网址。另外,您应该使用PrefixBasedActionProxyFactory来使用适当的工厂来构造与url匹配的操作。
https://stackoverflow.com/questions/14818010
复制相似问题