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 understand the action receiving parameters of struts2

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article will explain in detail how to understand the action receiving parameters of struts2. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Only receive parameter values (non-object)

If the parameters in Action are simply passed by the foreground,

For example, in Form

The method received in the background only needs to have setUserName ();, because it is a simple assignment.

Background object receive parameters

Format of the request: testAction? User.userName=admin

Then the object user is defined in Action:

Private User user = new User ()

At this point, there must be a getUser (); method, otherwise struts cannot find the corresponding object through reflection. As a result, you cannot assign values to specific properties in the object.

What distinguishes Action from java's getter and setter: the treatment of Boolean types.

Java:

Boolean isFlag = false;set method: public void setFlag (boolean isFlag) {this.isFlag = isFlag;} get method: public boolean isFlag () {return isFlag;}

Struts:

Boolean isFlag = false;set method: public void setIsFlag (boolean isFlag) {this.isFlag = isFlag;} get method: public boolean getIsFlag () {return isFlag;}

Reflection must be done as described above, which is the reflection rule set by struts itself.

On how to understand the action reception parameters of struts2 is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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

Internet Technology

Wechat

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

12
Report