Library learning log (...) )

Source: Internet
Author: User

Add Library in BuildPath, is right-click Project->properties->java buildpath->libraries

Then click Add Library is added library according to the prompts to add,

Add a jar to an existing library, add an internal click Add jar, add an external click Add External JARS;

The life cycle of form forms in a Web application:

For example, use the login form for login:

 login.jsp:  <form name= " form1   method="  post   action="  manager.do?action=login  ; 
<servlet>    <servlet-name>action</servlet-name>    <servlet-class> org.apache.struts.action.actionservlet</servlet-class>    <init-param>      <param-name> config</param-name>      <param-value>/WEB-INF/struts-config.xml</param-value>    </ init-param>    <init-param>      <param-name>debug</param-name>      <param-value>3 </param-value>    </init-param>    <init-param>      <param-name>detail</ param-name>      <param-value>3</param-value>    </init-param>    <load-on-startup >0</load-on-startup>  </servlet>  <servlet-mapping>    <servlet-name> action</servlet-name>    <url-pattern>*.do</url-pattern>  </servlet-mapping>

Above is web. xml

Structs-config.xml:

<action name= "Managerform" path= "/manager" scope= "Request" type= "Com.action.Manager" validate= "true" >      <forward name= "Managerquery" path= "/manager.jsp"/>      <forward name= "Managerloginok" path= "/main.jsp"/ >      <forward name= "Manageradd" path= "/manager_ok.jsp?para=1"/> <forward name=      " Managerquerymodify "path="/manager_modify.jsp "/>

Manager.java:

Public Actionforward Execute (actionmapping mapping, actionform form,httpservletrequest request, HttpServletResponse Response) {String action = request.getparameter ("action"); System.out.println ("Gets the query string:" + action); if (action = = NULL | | "". Equals (Action)) {/* If there is no action action */return mapping.findforward ("error");} else if ("Login". Equals (Action)) {/* If it is a processing administrator login */return managerlogin (mapping, form, request, response);} else if (" Manageradd. Equals (action) {return Manageradd (mapping, form, request, response);} else if ("Managerquery". Equals ( Action) {return managerquery (mapping, form, request, response),} else if ("Managermodifyquery". Equals (Action)) {return Managermodifyquery (mapping, form, request, response);} else if ("Managermodify". Equals (Action)) {return managermodify (mapping, form, request, response);} else if ("Managerdel" . Equals (Action) {return Managerdel (mapping, form, request, response),} else if ("Querypwd". Equals (Action)) {return Pwdquery (mapping, form, request, response);} else if ("Modifypwd". Equals (Action)) {return modifypwd (mapping, form, request, response);} Request.setattribute ("Error", "Operation failed!") "); return Mapping.findforward (" error ");} Public Actionforward Managerlogin (actionmapping mapping, actionform form,httpservletrequest request, HttpServletResponse response) {Managerform Managerform = (managerform) form;managerform.setname (ManagerForm.getName ( ), Managerform.setpwd (Managerform.getpwd ());/* Passes Formbean that have administrator information to DAO Business layer processing (querying for the presence of that administrator account and password) */int ret = Managerdao.checkmanager (Managerform); System.out.print ("Verify the value of the result ret:" + ret);/* The Business layer returns 1 for validation success */if (ret = = 1) {/* Save user Account in session */httpsession session = Request.getsession (); Session.setattribute ("Manager", Managerform.getname ());/* to the controller, jump to the landing successful page */return Mapping.findforward ("Managerloginok");} else {request.setattribute ("error", "the administrator name or password you entered is wrong!") "); return Mapping.findforward (" error ");}}

The specific processing is the above content, the transfer of form and the entire process of request.

As for the puzzling action, the content

<form name= "Form1" method= "Post" action= "Manager.do?action=login" >
You can use this picture to explain:

Library learning log (...) )

Related Article

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.