JSP page Pass Value

Source: Internet
Author: User

Function:

Page A1 pass a value: ZSDWH, to the B page, then to the C page, then the C page then return the value to b page, b page back to the A1 page.

Page A2 pass a value: YWZX, to the B page, then to the C page, then the C page then return the value to b page, b page back to the A2 page.

(This is only for example A1-->B--C;C-->B-->A1)

Steps:

One, A1 page, value: ZSDWH assigned to RequestType

Second, according to the Struts configuration file, find the Shiftnetflowinfo method in the background action,

Third, add code in method Shiftnetflowinfo:

String RequestType = Request.getparameter ("RequestType");//Accept the value of RequestType from the foreground page: ZSDWH

Request.setattribute ("RequestType", RequestType);//Bring the value back to the foreground page after this method executes (temporarily named B page here)

Iv. based on the struts configuration file, find the page that jumps after the last method execution: shiftnetflowinfo.jsp

In the B page (shiftnetflowinfo.jsp), add the following code:

Vi. find the Snfhistory method in the background action based on the struts configuration file

Seven, add code in method Snfhistory:

String RequestType = Request.getparameter ("RequestType");//Accept the value of RequestType from the foreground page: ZSDWH

Request.setattribute ("RequestType", RequestType);//Bring the value back to the foreground page after this method executes (temporarily named C page here)

Eight, according to the Struts configuration file, find the last method to jump after the page: snfhistoryinfo.jsp

Nine, in the C page (snfhistoryinfo.jsp) Add the following code (too long to intercept the diagram, paste the code directly):

<c:if test= "${requesttype== ' ZSDWH '}" >
<input type= "button" name= "button" id= "button" value= "return" class= "Submit" onclick= "window.location.href=" <SKC: Go name= "shiftnetflow_shiftnetflowinfo" defaulturi= "shiftnetflow.do?requesttype=zsdwh" ></skc:go> "/>
</c:if>

Comments:

The last requesttype=zsdwh of the second line of code is to bring the value back to the background action method: Shiftnetflowinfo

According to the Struts configuration file:

  

Bring the value back to page B (shiftnetflowinfo.jsp)

Ten, in the B page, add Judgment method, if the value equals ZSDWH, click the Back button, according to the struts configuration file, will execute method: Getshiftnetflowsheettoedit

<c:if test= "${requesttype== ' ZSDWH '}" >
<input type= "button" name= "button" id= "button" value= "return" class= "Submit" onclick= "window.location.href=" <SKC: Go name= "Shiftnetflow_getshiftnetflowsheettoedit" defaulturi= "getshiftnetflowsheettoedit.do" </skc:go> "/ >
</c:if>

PS: Resolved, two pages (page A1, page A2), call the same method to jump to the same page (page b), click the Return button, you can jump back to the original page.

JSP page Pass Value

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.