struts2不再推荐使用Codebehind作为零配置插件
package com.fun.actions; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.Actions; import com.fun.service.LoginService; import com.opensymphony.xwork2.ActionSupport; public class LoginAction extends ActionSupport { private String str; @Actions({ @Action(value="login1",params={"str","这是已经注入的了!"}), @Action(value="login2") }) public String login(){ return "str"; } @Action(value="ggg") public String abc(){ return "abc"; } public String getStr() { return str; } public void setStr(String str) { this.str = str; } } ?
@InterceptorRef用于为指定Action引用lanjieq或者是拦截器栈。也就相当于strut.xml中位于<action../>元素内部的<interceptor-ref../>子元素的作用。使用@InterceptorRefAnnotation时,必须制定一个value属性,用于指定所引用的拦截器或拦截器栈的名字。相当于<interceptor-ref../>子元素里name属性的作用。
?