Instance:
Configuration of Struts.xml
<!--to open dynamic method, value to True-->
<constant name= "Struts.enable.DynamicMethodInvocation" value= "true"/>
<action name= "Login" class= "com.house.action.UserAction" method= "Dologin" >
<result name= "Success" type= "Redirectaction" >${nextAction}</result> <!--permission assignment go to the next action-->
</action>
<!--ordinary user-->
<action name= "Common" >
<result>/page/house_list.jsp</result>
</action>
<!--Administrator-->
<action name= "Manager" >
<result>/page/manage.jsp</result>
</action>
-------------------------------------------------------------------------------------------------------------
The writing in the Action code
Increase:
Private String nextaction; The name of the next action to implement the configuration of the dynamic results
Public String getnextaction () {
return nextaction;
}
public void Setnextaction (String nextaction) {
This.nextaction = nextaction;
}
How to sign in:
Login
Public String Dologin () throws Unsupportedencodingexception {
Calling the business logic layer
User temp = Biz.login (User.getusername (), User.getuserpass ());
if (temp!= null) {
if ("1". Equals (Temp.getisadmin ())) {
Nextaction = "common";
else if ("0". Equals (Temp.getisadmin ()) {
nextaction = "Manager";
}
Return "Success";
}
return "error";
}