STRUTS2 Beginner Struts2 Action receive user data mode

Source: Internet
Author: User

First, Introduction
To develop a Web application, you should first encounter the receipt of user input data, which is a traditional Web application called HttpServletRequest's GetParameter (Stringname) method to fetch data from the request. The web framework provides a data binding mechanism by which the framework obtains data from the request and binds it to a JavaBean object.
STRUTS2 provides a variety of ways to receive user input data.
Struts2 's action is completely decoupled from the web, and to get the data for the Web tier, you need to use Actioncontext, which provides an execution context for the action.

The action receives the user data each way
A, receive data mode one: Use domain object to receive user input
One of the drawbacks of STRUTS1 is that Struts1 uses Actionform to receive data entered by the user. In Struts2, it is supported to use domain objects directly to receive data entered by the user.

Example Login.jsp

writing the user class

writing the Loginaction class

Struts.xml


For illustrative purposes

B, receive data mode two: Use Modeldrivenaction


Loginaction class

page login.jsp
C, receive data mode three: Use the Action property to receive user input


Other parts do not need to be changed.

STRUTS2 Beginner Struts2 Action receive user data mode

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.