Get the App
SLTechnology News&Howtos  ›  Development  › 

How to analyze Struts2 Authentication Framework and user Registration

Shulou Source: shulou.com Published: 2022-06-02 03:27:04 09月26日 Update

How to analyze the Struts2 authentication framework and user registration? in view of this problem, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Compared with the Struts1 verification framework, Struts2 verification is much easier to use, makes the program clearer and easier to read, and makes full use of the role of configuration files, which can be regarded as a sign of decoupling.

The core code is as follows:

1. User registration page register.jsp

< ?xml:namespace prefix = s />

< s:fielderror>

< /s:fielderror>

< /FONT>

< !-- 读取显示提示信息 -->

< TABLE>

User name:

Password:

< INPUT type=password name=user.password>

Confirm password:

< INPUT type=password name=user.rePassword>

Age:

< INPUT name=user.age>

Birthday:

< INPUT name=user.birthday>

two。 Welcome page for successful registration welcome.jsp

Conglomeration ${user.userName}

3. Registration processing action RegisterAction

Package org.kingtoon.action

4. User Bean User.java

Package org.kingtoon.bean

5. Configure the verification file RegisterAction-validation.xml

< VALIDATORS>

Configuration file struts.xml loaded by default in the 6.struts2 framework

< STRUTS>

< CONSTANT name="struts.custom.i18n.resources" value="messageResource">

< /CONSTANT>

Load Struts configuration file web.xml when 7.web server starts

< ?XML:NAMESPACE PREFIX = [default] < web-app xmlns="http://java.sun.com/xml/ns/j2ee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

At this point, it's over. However, it is important to note:

1. Configure Struts2 to verify that the name of the xml document has the following format: Action name-validation.xml

two。 Verify that the type type in the document should be the same as the User attribute type in VO, otherwise a type conversion error will be reported

This is the answer to the question about how to analyze the Struts2 authentication framework and user registration. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Tags: Authentication user configuration framework file user registration analysis type question name password document more page help solution easy consistent successful simple Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple NVidia Xiaomi Shulou Information Microsoft