答:
action中要有对应的getXX setXX方法。get方法用来接收jsp中表单或者什么的传过来的值,set方法用来返回。
比如你在action是这样写的
public class AdminAction extends ActionSupport {
private String error;
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
public String execute(){
setError("返回给jsp页面的error");
return SUCCESS;
}
}
然后在struts配置文件(struts.xml中配置好),<action>...</action>
最后在jsp页面通过${error}就能接收到 setError("返回给jsp页面的error");设置的字符串:返回给jsp页面的error