系统:WIN8.1

数据库:Oracle 11GR2

开发工具:MyEclipse 8.6

框架:Spring3.2.9、SpringMVC3.2.9、MyBatis3.2.8


先看代码:

@RequestMapping(value="manager")
@Controller("managerController")
public class ManagerController { /**
* 后台用户登录
* @param request
* @param emp
* @return
*/
@RequestMapping(params="login" , method={RequestMethod.POST})
public String login(HttpServletRequest request , Employe emp){ request.getSession().setAttribute(SystemConstant.MANAGER, emp);
return "redirect:index.jsp";
} /**
* 后台用户退出
* @param request
* @return
*/
@RequestMapping(params="logout" , method={RequestMethod.POST,RequestMethod.GET})
public String logout(HttpServletRequest request){ request.getSession().removeAttribute(SystemConstant.MANAGER);
return "redirect:login.html";
}
}

类上面有配置RequestMapping,访问路径为 manager ,方法上面这次配置的是params,值为login和logout。
页面发起访问路径由 类的访问名称 + 方法的访问名称/参数名称

页面请看form的action ,如果是get方法或者超链接也是一样,当然要记得添加参数

<form class="form-horizontal" action="manager?login" method="post">
                    <div class="form-group">
                      <label class="control-label col-lg-3" for="inputEmail">账号</label>
                      <div class="col-lg-9">
                        <input type="text" class="form-control" id="inputEmail" placeholder="账号" name="empName">
                      </div>
                    </div>
                    <div class="form-group">
                      <label class="control-label col-lg-3" for="inputPassword">密码</label>
                      <div class="col-lg-9">
                        <input type="password" class="form-control" id="inputPassword" placeholder="密码" name="empPassword">
                      </div>
                    </div>
                        <div class="col-lg-9 col-lg-offset-2">
                            <button type="submit" class="btn btn-danger">登陆</button>
                            <button type="reset" class="btn btn-default">重置</button>
                        </div>
                    <br />
                  </form>

SpringMVC + Spring + MyBatis 学习笔记:在类和方法上都使用RequestMapping如何访问的更多相关文章

  1. SpringMVC + Spring + MyBatis 学习笔记:SpringMVC和Spring一同工作的时候,AOP事务管理不起作用的解决方法

    系统:WIN8.1 数据库:Oracle 11GR2 开发工具:MyEclipse 8.6 框架:Spring3.2.9.SpringMVC3.2.9.MyBatis3.2.8 SpringMVC 的 ...

  2. SpringMVC + Spring + MyBatis 学习笔记:提交数据遭遇基础类型和日期类型报400错误解决方法

    系统:WIN8.1 数据库:Oracle 11GR2 开发工具:MyEclipse 8.6 框架:Spring3.2.9.SpringMVC3.2.9.MyBatis3.2.8 使用SpringMVC ...

  3. SpringMVC + Spring + MyBatis 学习笔记:遭遇order by 排序问题

    系统:WIN8.1 数据库:Oracle 11GR2 开发工具:MyEclipse 8.6 框架:Spring3.2.9.SpringMVC3.2.9.MyBatis3.2.8 用MyBatis写排序 ...

  4. SpringMVC + Spring + MyBatis 学习笔记:为MyBatis增加打印SQL功能 (最简化配置)

    系统:WIN8.1 数据库:Oracle 11GR2 开发工具:MyEclipse 8.6 框架:Spring3.2.9.SpringMVC3.2.9.MyBatis3.2.8 1.以下jar包拷贝到 ...

  5. Mybatis学习笔记(三) —— DAO开发方法

    一.SqlSession的使用范围 SqlSession中封装了对数据库的操作,如:查询.插入.更新.删除等. SqlSession通过SqlSessionFactory创建. SqlSessionF ...

  6. springmvc学习总结(二) -- maven+springmvc+spring+mybatis+mysql详细搭建整合过程讲解

    @_@ 写在最前 之前分享过下面这几篇: mybatis学习笔记(五) -- maven+spring+mybatis从零开始搭建整合详细过程(上)(附demo和搭建过程遇到的问题解决方法) myba ...

  7. mybatis学习笔记(六) -- maven+spring+mybatis从零开始搭建整合详细过程(下)

    继续 mybatis学习笔记(五) -- maven+spring+mybatis从零开始搭建整合详细过程(上) 五.使用监听器启动Spring容器 1.修改pom.xml文件,添加Spring-we ...

  8. 第04项目:淘淘商城(SpringMVC+Spring+Mybatis) 的学习实践总结【第二天】

    淘淘商城(SpringMVC+Spring+Mybatis)  是传智播客在2015年9月份录制的,几年过去了.由于视频里课上老师敲的代码和项目笔记有些细节上存在出入,只有根据日志报错信息作出适当的调 ...

  9. 第04项目:淘淘商城(SpringMvc+Spring+Mybatis) 的学习实践总结【第三天】

    淘淘商城(SpringMVC+Spring+Mybatis)  是传智播客在2015年9月份录制的,几年过去了.由于视频里课上老师敲的代码和项目笔记有些细节上存在出入,只有根据日志报错信息作出适当的调 ...

随机推荐

  1. python抓取百度热词

    #baidu_hotword.py #get baidu hotword in news.baidu.com import urllib2 import os import re def getHtm ...

  2. js学习之道:表单验证公共js

    /** 文件名称:CommonUtil.js 作者  : Yuce 编制时间: 2010-03-24 文件内容:一些常用的js公用类.工具类 包括方法: g_FormFieldIsNull    判断 ...

  3. 如何修改linux时间? 校正linux系统的时间

    第一步:通过xshell远程连接到linux系统 第二步:输入 tzselect 第三步:选择所在的州,中国人请选择 5 ,亚洲 第四步:选择你所在的国家,中国人请选择9,中国 第五步:选择一个时区, ...

  4. [转]c/c++输入函数

    最全输入函数 c/c++ 一: c=getchar(); 功能:读入一个字符 说明:调用此函数时要求在程序的第一行有预编译命令:#include<stdio>,不过在做c++时 有#inc ...

  5. laravel中的命名公约规范及relation N+1问题

    User: model  ;  users: 表名: user_id 键值 relation: public function tasks(){return $this->belongsToMa ...

  6. git workflow常用命令

    git init git status git add readme.txt git add --all         Adds all new or modified files git comm ...

  7. jsp之EL表达式

    1.null值 null值会用""进行显示 2.隐式对象 1).pageScope.requestScope(相当于request).sessionScope(相当于session ...

  8. 读取Properties文件工具类

    import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java ...

  9. HDU 1018 Big Number (阶乘位数)

    题意: 给一个数n,返回该数的阶乘结果是一个多少位(十进制位)的整数. 思路: 用对数log来实现. 举个例子 一个三位数n 满足102 <= n < 103: 那么它的位数w 满足 w ...

  10. HDU1495 非常可乐

    解题思路:简单的宽搜,见代码: #include<cstdio> #include<cstring> #include<algorithm> #include< ...