Reputation: 2280
The problem seems silly because I properly misunderstood the document. Basically I just want to run the hello-world actionless example according to this instruction by simply adding hello.jsp file into WEB-INF/content and then running localhost:8080/test/hello, but Struts keeps showing the exception java.lang.NoSuchMethodException: com.opensymphony.xwork2.ActionSupport.index().
So I wonder there is any configuration need to be done before running. I couldn't find any thing about configuration for hello-world example.
Could anyone suggest me correct way ? Thanks
Updated: here is project tree, no action, no any fancy.
├── pom.xml
└── src
└── main
├── resources
│ └── struts.xml
└── webapp
├── WEB-INF
│ ├── content
│ │ └── hello.jsp
│ └── web.xml
└── index.jsp
The dependencies in 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>
Upvotes: 1
Views: 2026
Reputation: 1017
You have mixed the Struts 2 Convention plugin with the Struts 2 REST plugin and that's why Struts 2 is looking for method called index() (default method for REST).
Remove the REST plugin - struts2-rest-plugin
- and everything should work as expected.
If you want to mix Convention with REST consult the docs, eg. you can use struts.rest.namespace
to distinguish REST part of the application from normal web application part.
EDIT
If you want to mix both parties - a normal web app and REST endpoints - you can consider using PrefixBasedActionMapper which allows use different mappers per url. Plus you should use PrefixBasedActionProxyFactory
to use proper factories to construct actions that will match the url.
Upvotes: 10