系统: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. C# 打印小票 POS

    C# 打印小票 POS 最近在写一个餐饮的收银系统,以前从来没有碰过打印机这玩意.感觉有些无从下手,在前面做报表时,总想找第三方的控件来用用,结果始终不行没搞定.没研究透,催得急没办法还是的动手自己写 ...

  2. PL/SQL 如何导出INSERT语句

    需要把查询出来的数据导出成Insert的语句.忽然发现不会用了. 上网查,找到一些,但都不尽如人意. 于是就写了这篇文章.助人助己. 在PL/SQL Developer左边的树状导航栏里,找到[Tab ...

  3. HTML 空格的表示符号 nbsp / ensp / emsp 的区别?

      半角的不断行的空白格(推荐使用)   半角的空格   全角的空格   半角的不断行的空白格(推荐使用)    半角的空格     全角的空格

  4. 【Todo】深入理解Java虚拟机 读书笔记

    有一个在线系列地址 <深入理解Java虚拟机:JVM高级特性与最佳实践(第2版)> http://book.2cto.com/201306/25426.html 已经下载了这本书(60多M ...

  5. HibernateTemplate 查询

    Spring中常用的hql查询方法getHibernateTemplate()上     一.find(String queryString);   示例:this.getHibernateTempl ...

  6. 线程中无法实例化spring注入的服务的解决办法

    问题描述 在Java Web应用中采用多线程处理数据,发现Spring注入的服务一直报NullPointerException.使用注解式的声明@Resource和XML配置的bean声明,都报空指针 ...

  7. PHP的模板引擎这点事儿

    什么是模板引擎? 为什么要使用它? 为什么要assign一个变量给模板? https://dbforch.wordpress.com/2010/06/26/the-logic-behind-templ ...

  8. UVa 12325 Zombie's Treasure Chest【暴力】

    题意:和上次的cf的ZeptoLab的C一样,是紫书的例题7-11 不过在uva上交的时候,用%I64d交的话是wa,直接cout就好了 #include<iostream> #inclu ...

  9. singleton单例模式

    单例设计模式 单例设计模式概述    单例模式就是要确保类在内存中只有一个对象,该实例必须自动创建,并且对外提供    优点:    在系统内存中只存在一个对象,因此可以解决系统资源,对于一些需要频繁 ...

  10. C的结构体使用

    C的结构体演示 #include <stdio.h> struct A //建立结构体A { char *name; int s1; struct A *next; }; void mai ...