Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to analyze Struts2 Authentication Framework and user Registration

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report