简体   繁体   English

struts2:在main / calling jsp中显示结果jsp

[英]struts2: display result jsp in the main/calling jsp

I have a one main jsp (file upload jsp screen) which has form elements. 我有一个main jsp (文件上传jsp屏幕),它有表单元素。 User will select the file to upload, also set some other elements (such as checkboxes, radios, etc.) as per the requirement and then finally submit the form. 用户将选择要上传的文件,还可以根据要求设置其他一些元素(如复选框,无线电等),最后提交表单。

After uploading the result of the process is formulated into a table of a different JSP (say result.jsp ). 上传后的过程结果被制定成一个不同JSP的表(比如result.jsp )。 Right now the result.jsp is displayed independently on the screen. 现在,result.jsp在屏幕上独立显示。

What I want is to display the result.jsp in the same parent.jsp (having form elements) and not on a separate independent page. 我想要的是在同一个parent.jsp (具有表单元素)中显示result.jsp而不是在单独的独立页面上。

Can anyone help me with this? 谁能帮我这个?

struts.xml: struts.xml中:

<action name="commonDataImportAction_*" class="commonDataImportAction">
        <result name="VIEW">
            /jsp/CommonDataImportLog.jsp (result.jsp)
        </result>
        <result name="input">/jsp/CommonDataImport.jsp (parent.jsp)
        </result>
</action>

Update: 更新:

Screenshot of the screen, how I want it: 屏幕截图,我想要的方式:

http://img802.imageshack.us/img802/7141/screenzgk.jpg http://img802.imageshack.us/img802/7141/screenzgk.jpg

If you are submitting the page in simple manner the way Struts2 submit button works than one simple solution is to create only a single page which also contains the layout of your result.jsp , but you can hide that part initially (before the page submit). 如果您以简单的方式提交页面,Struts2提交按钮的工作方式比一个简单的解决方案是只创建一个也包含result.jsp布局的单个页面,但您最初可以隐藏该部分(在页面提交之前) 。

On successful page submission you can set a value (say a Boolean) in your action class and based on this can show that section,since your are already done with file upload so you can set those values in your action class which are needed to show the values in result.jsp . 成功提交页面后,您可以在操作类中设置一个值(例如布尔值),并根据此显示该部分,因为您已完成文件上传,因此您可以在操作类中设置需要显示的值result.jsp的值。

For me that is a simple yet efficient approach. 对我来说这是一种简单而有效的方法。

Alternatively if you are going with the Ajax based file upload than there are many ways to do this like 或者,如果你要使用基于Ajax的文件上传,那么有很多方法可以做到这一点

  1. Send back HTML section from the Action. 从Action发回HTML部分。
  2. You can even send the name of JSP file and can include it in to the current JSP at runt time. 您甚至可以发送JSP文件的名称,并可以在较短的时间将其包含在当前的JSP中。
  3. Send JSON data from action and parse the JSON using Jquery to build view 从操作发送JSON数据并使用Jquery解析JSON以构建视图

As i found u have to redirect it to same page (parent.jsp). 因为我发现你必须将它重定向到同一页面(parent.jsp)。 You have to remove another one. 你必须删除另一个。

And make some change in parent.jsp. 并在parent.jsp中进行一些更改。 Like use of iterator tag and all which is useful for display all your data. 就像使用iterator标签一样,所有这些都可用于显示所有数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM