In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to use Strust2, the introduction in the article is very detailed, has a certain reference value, interested friends must read!
1: variables defined in action are displayed on the jsp page with:
2: automatically increase the sequence number in the page with the index attribute eg of iterator's statuts:
3: methods to get request and session objects in the action class
Map session = ActionContext.getContext () .getSession (); HttpServletRequest request = ServletActionContext.getRequest ()
The method of setting their values
Session.put ("operation", "add"); request.setAttribute ("name", name)
Get their values from the page:
4: different control methods for odd and even rows on the page:
5: how to use radio boxes and check boxes
1): you can set the default selection value, and pay attention to the setting of the value of list, which makes key different from value in this way. This method is more commonly used (checkboxlist or radio).
2): the values of key and value here are the same (checkboxlist or radio)
Tags in 6:struts2 will generate strings similar to those made up of them (specific what tags generate what, you can view the source code of the generated page) if you do not limit the generation of these redundant code, the page will become uncontrollable, so generally we do not want it to generate redundant code, the specific setting method if, unified configuration in struts.xml
You can also cancel the default table layout by setting the theme property of tag to "simple" on the page, but *: customize a theme and set it to apply to the entire site by default, so you can get a unified site style.
The method of formatting date in 7:jsp Page
This allows you to format the date in the form of yyyy-MM-dd
8: by default, when a request for action occurs, the Struts runtime (Runtime) instantiates the class corresponding to action and calls its execute method based on the Action mapping set (Mapping) in struts.xml. Of course, we can change this default call in two ways
1) create a new Action in classes/sturts.xml and indicate the method it calls
For example, you want to call the
Public String aliasAction () {message = "Custom Action calling method"; return SUCCESS;}
Add the following code to the classes/sturts.xml:
/ HelloWorld.jsp
You can call this method under the name of action.
2) (more commonly used)
When accessing Action, add "! xxx" after the Action name (xxx is the method name).
9:Struts 2.0 has two configuration files, struts.xml and struts.properties are placed under WEB-INF/classes/.
Struts.xml is used for application-related configuration
Struts.properties for run-time (Runtime) configuration of Struts 2.0
10: the method of getting the physical path (absolute path) of a folder under web in the action class
FilePath = ServletActionContext.getServletContext () .getRealPath ("/ upLoadFiles")
11: to return a page that is not a direct JSP page, but to read the corresponding data by returning the method in action and then return to the jsp page, there are two ways
1) set this in struts.xml
Sysmanage/UserBaseInfoAction!findUserBaseInfo.action
2) call this method directly when it is returned in action
Return findList ()
12: method of setting default values in checkboxlist
13: secondary cascade drop-down box
14: extract the property values from the list object in the page
The above is all the contents of this article "how to use Strust2". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.