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