我试图在我的项目中实现Struts 2注释,但我不知道如何。Struts2 - 如何使用Struts2注释?
我加入了公约,插件版本2.1.8.1我POM
我修改了的web.xml
...
<init-param>
<param-name>actionPackages</param-name>
<param-value>org.apache.struts.helloworld.action</param-value>
</init-param>
...
我的行动
package org.apache.struts.helloworld.action;
import org.apache.struts.helloworld.model.MessageStore;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
@Results({
@Result(name="success", location="HelloWorld.jsp")
})
public class HelloWorld extends ActionSupport {
public String execute() throws Exception {
messageStore = new MessageStore() ; return SUCCESS;
}
JSP页面从我尝试使用我的动作的地方
<body>
<h1>Welcome To Struts 2!</h1>
<p><a href="<s:url action='helloWorld'/>">Hello World</a></p>
</body>
当我按下相关的行动的helloWorld的联系,但它把我送到了一模一样的页面。因此,从index.jsp发送到index.jsp。
它应该表现的方式:它应该将我发送到HelloWorld.jsp。
我上传了一个项目(一个非常简单的HelloWorld应用程序)到FileFront,也许有人看到问题在哪里。 http://www.filefront.com/16364385/Hello_World.zip