Add Ajax effects for Form Verification of struts2

Source: Internet
Author: User
This article introduces how to add Ajax effects to form verification of struts2.
First, DWR servlet (UK. Ltd. getahead. DWR. dwrservlet) dojo and Ajax theme are required. DWR is used for normal verification of dojo to process Ajax results.
Next, configure DWR, write DWR. XML, and store it in the WEB-INF. The content is as follows:
<!DOCTYPE dwr PUBLIC 
"-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN"
"http://www.getahead.ltd.uk/dwr/dwr10.dtd">

<dwr>
<allow>
<create creator="new" javascript="validator">
<param name="class" value="org.apache.struts2.validators.DWRValidator"/>
</create>
<convert converter="bean" match="com.opensymphony.xwork2.ValidationAwareSupport"/>
</allow>

<signatures>
<![CDATA[
import java.util.Map;
import org.apache.struts2.validators.DWRValidator;

DWRValidator.doPost(String, String, Map<String, String>);
]]>
</signatures>
</dwr>

Then you need to configure it to a web program and add the following configuration code to Web. xml: <servlet>
<Servlet-Name> DWR </servlet-Name>
<Servlet-class> UK. Ltd. getahead. DWR. dwrservlet </servlet-class>
<Init-param>
<Param-Name> debug </param-Name>
<Param-value> true </param-value>
</Init-param>
</Servlet>

<Servlet-mapping>
<Servlet-Name> DWR </servlet-Name>
<URL-pattern>/DWR/* </url-pattern>
</Servlet-mapping>

Finally, modify the JSP file edit. jsp in my struts2 Form Verification Article.
Add Ajax theme to the head, and add validate = "true" theme = "ajax" to the form. Now you can run it to experience the Ajax effect.

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.