我試圖在我的項目中實現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