Struts 2 + Jquery + JSON (login verification)

Source: Internet
Author: User
Tags sendmsg string back

Struts 2 + Jquery + JSON (login verification) 16:47:39 | category: Java Web | font size subscription there are many articles about Struts2 and JSON on the internet, Google and Baidu, read a lot, there are a variety of practices. In most articles, a plug-in called jsonplugin is added, which can be downloaded from Google Code. I have tested it before and used it, but it is really troublesome. Let the Struts2 package inherit a parent package named "json-default. Most of the online articles are about how to send JSON data back to the browser (Ajax) from the Struts Action ), however, I want a process opposite to them (that is, sending data from Ajax to the Action on the server side and parsing it), but I cannot find a proper answer. Three nights of exploration, unsuccessful. Today, I finally found my thoughts. Among them, whether sent from the browser side (JS, Ajax, Jquery, etc.) to the server side, or sent back to the client from the server side (Struts Action, Servlet, etc.), you must identify one point: all sent strings must be in JSON format. Under www.2cto.com, we will first rewrite the loginform In the login module. jsp file. For the original code, see the Struts 2.1.6 simplified instance series tutorial (2): Implementation of the user login module. The modified code is as follows: <% @ page language = "java" contentType = "text/html; charset = UTF-8 "pageEncoding =" UTF-8 "%> <% @ taglib prefix =" s "uri ="/struts-tags "%> <! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" http://www.w3.org/TR/html4/loose.dtd "> www.2cto.com

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.