struts2 在 struts.xml 配置文件中引用action 类中的属性
java 类如下
import com.opensymphony.xwork2.ActionSupport;public class LoginAction extends ActionSupport{ private String role = ""; public String getRole() { return role; } public void setRole(String role) { this.role = role; } @Override public String execute() throws Exception { // TODO Auto-generated method stub return SUCCESS; }}
?
struts.xml中配置action map时 以如下形式进行引用${filed},注意和type没有关系
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"><struts> <package name="default" extends="struts-default"> <action name="login" type="chain">${role}</result> </action> <action name="admin"> <result>admin.jsp</result> </action> <action name="user"> <result>user.jsp</result> </action> </package> </struts>
?