springmvc+mybatis+oracle简单登录
2017-05-17 18:10
344 查看
之前整合了SpringMVC和mybatis
http://blog.csdn.net/nmj2015/article/details/72353936
现在我们在之前的基础上做一个简单的登录功能。
关于注解:
Controller:@Controller
Service:@Service(“userServiceImpl”)
Dao:@Component(“usersDao”)
其中@Autowired是由SpringMVC自动匹配相应对象
一. 在dao中新建根据user_name查询Priv_User信息的方法,以便于我们通过用户名查询用户信息后与密码匹配
并在mapper中实现此方法
二. 建立Priv_UserService接口
三. 实现此接口,在这里用@Autowired来注解Priv_UserDao,并且处理一些登录逻辑
四. 在Crotoller中写登录方法,如果登录成功跳转到success,失败跳转fail
五. 在index.jsp中写form来登录
六. 测试。
源码:http://download.csdn.net/detail/nmj2015/9845288
后面准备写一下log的配置和session过滤
http://blog.csdn.net/nmj2015/article/details/72353936
现在我们在之前的基础上做一个简单的登录功能。
关于注解:
Controller:@Controller
Service:@Service(“userServiceImpl”)
Dao:@Component(“usersDao”)
其中@Autowired是由SpringMVC自动匹配相应对象
一. 在dao中新建根据user_name查询Priv_User信息的方法,以便于我们通过用户名查询用户信息后与密码匹配
public Priv_User queryByUserName(Object user_name);
并在mapper中实现此方法
<select id="queryByUserName" resultMap="BaseResultMap" parameterType="Object"> select <include refid="Base_Column_List" /> from PRIV_USER where user_name = #{user_id} </select>
二. 建立Priv_UserService接口
package eesofa.cn.service; import eesofa.cn.bean.Priv_User; public interface Priv_UserService { /**** * 登录 * @param user_name * @param password * @return */ public Priv_User login(String user_name, String password); }
三. 实现此接口,在这里用@Autowired来注解Priv_UserDao,并且处理一些登录逻辑
@Service("priv_UserService") public class IPriv_UserService implements Priv_UserService { @Autowired private Priv_UserDao priv_UserDao; @Override public Priv_User login(String user_name, String password) { // TODO Auto-generated method stub if (user_name != null && password != null && !user_name.equals("")&& !password.equals("")) { Priv_User user = priv_UserDao.queryByUserName(user_name); if (user!=null&&user.getPassword()!=null&&user.getPassword().equals(password)) { return user; } } return null; } }
四. 在Crotoller中写登录方法,如果登录成功跳转到success,失败跳转fail
@Autowired private Priv_UserService priv_UserService; @RequestMapping("/login") public String login(String user_name, String password) { Priv_User priv_User= priv_UserService.login(user_name, password); if(priv_User!=null){ return "success"; } return "fail"; }
五. 在index.jsp中写form来登录
<form action="login" method="post"> <fieldset> <legend>登录</legend> <p> <label>姓名:</label> <input type="text" id="user_name" name="user_name" tabindex="1"> </p> <p> <label>密码:</label> <input type="text" id="password" name="password" tabindex="2"> </p> <p id="buttons"> <input id="reset" type="reset" tabindex="4" value="取消"> <input id="submit" type="submit" tabindex="5" value="登录"> </p> </fieldset> </form>
六. 测试。
源码:http://download.csdn.net/detail/nmj2015/9845288
后面准备写一下log的配置和session过滤
相关文章推荐
- springmvc+mybatis+sql server实现简单登录功能【转】
- springmvc+mybatis+sql server实现简单登录功能【转】
- springmvc+mybatis+sql server实现简单登录功能
- springmvc+spring+mybatis(简单登录)+aop日志管理
- springmvc+mybatis+sql server实现简单登录功能【转】
- springmvc+mybatis+sql server实现简单登录功能【转】
- springmvc+mybatis+sql server实现简单登录功能【转】
- springmvc+mybatis+sql server实现简单登录功能
- spring mvc + mybatis + mysql 整合的一个简单的登录例子
- springmvc+mybatis+sql server实现简单登录功能
- springmvc+mybatis+sql server实现简单登录功能【转】
- mybatis+oracle+springMVC实现简单分页
- 菜鸟级springmvc+spring+mybatis整合开发用户登录功能(上)
- sping+springmvc+mybatis登录
- java web应用开发简单梳理(mybatisl+springMvc+tomcat)
- maven+spring+springmvc+mybatis+ajax 框架下实现简单的聊天室
- 简单配置spring+springmvc+mybatis之整合
- Spring MVC +MyBatis +MySQL 登录查询Demo 解决了mybatis异常【转】
- 使用注解springmvc+spring+mybatis一个简单ajax例子
- Spring MVC + mybatis实现的注册登录