JavaWeb编程登录验证失败问题
新上手小白web,验证过数据库都没问题,表单数据可以传入数据库并搜索到结果,但是好像传不回来,求大佬指点指点。关键代码如下:(点个思路就行了)
数据库的xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.itheima.core.dao.UserDao" >
<!-- 查询用户 -->
<select id="findUser" parameterType="String" resultType="user">
select *
from admin
where boss_username = #{usercode}
and boss_password =#{password}
and boss_state = '1'
</select>
</mapper>
出现问题的部分:(下面的syso输出user为空)
package com.itheima.core.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.itheima.core.dao.UserDao;
import com.itheima.core.po.User;
import com.itheima.core.service.UserService;
/**
* 用户Service接口实现类
*/
@Service("userService")
@Transactional
public class UserServiceImpl implements UserService {
// 注入UserDao
@Autowired
private UserDao userDao;
// 通过账号和密码查询用户
@Override
public User findUser(String usercode, String password) {
User user = this.userDao.findUser(usercode, password);
System.out.println(user+"*******"+usercode+" "+password);
return user;
}
}
出现主要问题:
上图可以连接数据库,密码错误
上两图的print输出user为空,帐号和密码传值正常,并且数据库total为1能搜到数据
为什么会null?不懂,求大神指点。