Question about the value of not action for the JSP page corresponding to the IFRAME in the struts2 frame __div

Source: Internet
Author: User
We often use frameset, frame, and IFRAME to do Web projects, which greatly facilitates the construction of our pages and the partitioning of the functions of modules. However, the use of these technologies will also encounter a variety of problems, one of which is the child page can not get the value of struts2 action. I had this problem when I was working on a project. Read a lot of information on the Internet, and now will be their own summary and conclusions to share with you.
Frameset, frame by practice is no problem, if for various reasons also appear, then please refer to the IFRAME.
Now to discuss the problem of IFRAME specifically:
The first thing to be clear about this problem is that the action Valuestack, Stackcontext can reach the scope (I temporarily call it the scope of action, not necessarily accurate, but easy to understand) only to the first JSP page of result jump , that is, the value of the current action is only available on this JSP page, and other pages are not available (other JSP values are the value of the other action).
To solve the problem of IFRAME, the above sentence must be understood.
Here's a look at the use of iframe: <iframe src = "***.jsp"/>
You can see that the src of the IFRAME exactly corresponds to another JSP page, so this JSP page is not available (if there is no other action directly jump to the JSP page).
So how to solve this problem, <iframe src = "***.action"/>
Not change the suffix name, but let the src point to a action,action corresponding method to complete the corresponding additions and deletions to check the operation, and finally return a page, then this page is used in this IFRAME
For the convenience of home understanding, the following paste an example for everyone to refer to:
mainframe.jsp <%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%> <!   DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01transitional//en" >
Struts.xml
<package name= "front" namespace= "extends=" Struts-default "> <!--the first * represents which action you use, and the second is the method you use--> <action name= "*_*" class= "Com.blog.action". {1} Action "method=" {2} "> <resultname=" menu ">/menu.jsp</result> <resultname=" list ">/ List.jsp</result> </action> </package>

Blogaction.java
public String menu () {menus = Blogservice.getmenu (), Return "menu",} public string list () {blogs = blogservice.getlist (); return "List"; }

menu.jsp
<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%> <%@ taglib uri= "/struts-tags" prefix= "s" %> <!   DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01transitional//en" >
list.jsp
<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%> <%@ taglib uri= "/struts-tags" prefix= "s" %> <!   DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01transitional//en" > If it's easy to figure it out, but there's a problem with customary writing, which is the same query that used to be the same, and then it's displayed uniformly on the page.
Blogacton.java
Public String list () {menus = Blogservice.getmenu (), blogs = Blogservice.getlist (); return "Success";}

blog.jsp
<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%> <%@ taglib uri= "/struts-tags" prefix= "s" %> <!   DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01transitional//en" > <s:iterator value= "Blogs" > <s:property value= "title" > </s:iterator> </body> But now it is: by Dahua small, by the simplification, toward an action method to solve a functional direction, but this is what we need. In view of my limited technology can only be analyzed to this, if there are any problems I hope you correct me.

Reprint Address: http://blog.sina.com.cn/s/blog_4f8d3e340100v3xc.html
Related Article

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.