Struts2.5.2简单的使用注解
导入需要的包
- asm-3.3.jar
- asm-commons-3.3.jar
- commons-fileupload-1.3.2.jar
- commons-io-2.4.jar
- commons-lang3-3.4.jar
- commons-logging-1.1.3.jar
- freemarker-2.3.23.jar
- javassist-3.20.0-GA.jar
- log4j-api-2.5.jar
- log4j-core-2.5.jar
- ognl-3.1.10.jar
- struts2-convention-plugin-2.5.2.jar
- struts2-core-2.5.2.jar
HelloAction.java
package com.action;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import com.opensymphony.xwork2.ActionSupport;
@ParentPackage(value = "struts-default")
@Namespace("/")
public class HelloAction extends ActionSupport {
@Action(value = "/hello", results = { @Result(name = "success", location = "/index.jsp") })
public String execute() {
System.out.println("hello action");
return "success";
}
}
部署项目后后直接访问项目 项目名/hello.action