SPRINGMVC + Spring + MyBatis Learn notes: Use Requestmapping on classes and methods to access

Source: Internet
Author: User

System: WIN8.1

Database: Oracle 11GR2

Development tools: MyEclipse 8.6

Frames: Spring3.2.9, SpringMVC3.2.9, MyBatis3.2.8

Look at the code first:

@RequestMapping (value= "Manager")@Controller ( "managercontroller") Public classManagercontroller {/*** Background User login *@paramRequest *@paramEMP *@return     */@RequestMapping (params="Login", method={requestmethod.post}) PublicString Login (httpservletrequest request, Employe EMP) {request.getsession (). SetAttribute (Systemconsta Nt.        MANAGER, EMP); return"Redirect:index.jsp"; }            /*** Background User exit *@paramRequest *@return     */@RequestMapping (params="Logout", method={requestmethod.post,requestmethod.get}) PublicString Logout (httpservletrequest request) {request.getsession (). RemoveAttribute (Systemconstant.manager        ); return"Login"; }}

Class has configuration requestmapping, Access path to Manager, the method above this configuration is the params, the value is login and logout.
Page-Initiated access Path by class Access name + method access Name/parameter name

Page please look at the action of the form, if it is a Get method or hyperlink is the same, of course, remember to add parameters

<FormClass= "Form-horizontal"Action="Manager?login"Method= "POST">
<DivClass= "Form-group">
<LabelClass= "Control-label col-lg-3"For= "Inputemail"> Account</Label>
<DivClass= "Col-lg-9">
<InputType= "Text"Class= "Form-control"Id= "Inputemail"Placeholder= "Account"Name= "EmpName">
</Div>
</Div>
<DivClass= "Form-group">
<LabelClass= "Control-label col-lg-3"For= "Inputpassword"> Password</Label>
<DivClass= "Col-lg-9">
<InputType= "Password"Class= "Form-control"Id= "Inputpassword"Placeholder= "Password"Name= "Emppassword">
</Div>
</Div>
<DivClass= "Col-lg-9 col-lg-offset-2">
<buttonType= "Submit"Class= "Btn Btn-danger"> Login</button>
<buttonType= "Reset"Class= "Btn Btn-default"> Reset </button>
</Div>
<br />
</form>

Springmvc + Spring + MyBatis Learning notes: Using Requestmapping on classes and methods how to access

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.