Pop-up window Session is lost and duplicated submission form is prevented.

First, pop-up window Session lost.

Popup window Session lost
Using window.showModalDialog to prompt information is quite convenient and easy to control appearance and layout. But there is a serious problem, that is, Session is missing. When showModalDialog is performed on the A page, the ejected moduleWhen the state window opens a new page or new dialog (), it gets no Session in the A page, which severely limits its scope of use.
Further use of the mode window shows that the loss of session always follows the refresh of the page.
1.All page sessions in the process are lost when a mode window pops up in a normal page and a new dialog () operation is performed

2.The mode window that pops up when the mode window is nested does not lose the session of the parent mode window but does not get the value of the parent mode window

3.If a statement such as return true or false appears when a JS script is used to validate a form in a pop-up modal window, the modal window session will be lost.

ShowModalDialog often has such strange problems, so it is best to use showModalDialog less. The alternative is to use DIV to simulate the same function as the mode window.

 

Two, prevent duplication of forms.

<s:token/>Labels prevent repeated submission:
1、Add &lt to the form; s:token/>
<s:form action=”helloworld_other” method=”post” namespace=”/test”>
 <s:textfield name=”person.name”/><s:token/><s:submit/> 
</s:form>
2、Configuring Interceptors
<action name=”helloworld_*” class=”cn.itcast.action.HelloWorldAction” method=”{1}”>
 <interceptor-ref name=”defaultStack”/>
 <interceptor-ref name=”token”/>
 <result name=”invalid.token”>input.jsp</result>
 <result>/WEB-INF/page/result.jsp</result>
</action>
When the token interceptor does not agree with the requested token in the session, the invalid. token result is returned directly.
The following information appears in the debug status console because there are no struts. token and struts. token. name attributes in the Action, so don’t care.
Serious: Parameter sinterceptor – [setParameters]: UnexpectedException caught set’struts. token’on’class XXXError’…
Serious: ParametersInterceptor-[setParameters]:…

Leave a Reply

Your email address will not be published. Required fields are marked *