Dynamic result configuration: In Struts.xml, the type configuration of a property is Redirectaction (the request is redirected to the specified action) __struts.xml

Source: Internet
Author: User

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";
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.