我们直接切人正题,不多逼逼赖赖
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.1..RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.1..RELEASE</version>
</dependency>
<dependency>
<groupId>javaee</groupId>
<artifactId>javaee-api</artifactId>
<version></version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
public class Smbms_User implements Serializable {
private Integer id;
private String usercode;
private String username;
private String userpassword;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsercode() {
return usercode;
}
public void setUsercode(String usercode) {
this.usercode = usercode == null ? null : usercode.trim();
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username == null ? null : username.trim();
}
public String getUserpassword() {
return userpassword;
}
public void setUserpassword(String userpassword) {
this.userpassword = userpassword == null ? null : userpassword.trim();
}
}
@Repository
public interface Smbms_UserMapper {
@Select("select \* from smbms\_user where userCode=#{user\_code} and userPassword=#{user\_password}")
public Smbms\_User login(@Param("user\_code") String user\_code, @Param("user\_password") String user\_password);
}
public interface Smbms_UserService {
public Smbms\_User login(String user\_code, String user\_password);
}
@Service("smbms_UserService")
public class Smbms_UserServcieImpl implements Smbms_UserService {
//植入Dao层对象
@Resource
private Smbms_UserMapper smbms_userMapper;
//事务
/* @Transactional(isolation=Isolation.DEFAULT)*/
@Override
public Smbms_User login(String user_code, String user_password) {
return smbms_userMapper.login(user_code,user_password);
}
}
@Controller
@RequestMapping("/user")
public class Smbms_UserController {
//植入Service层分对象
@Resource
private Smbms_UserService smbms_userService;
@RequestMapping("/login")
public String doLogin(Smbms\_User smbms\_user, HttpSession session){
Smbms\_User user = smbms\_userService.login(smbms\_user.getUsercode(), smbms\_user.getUserpassword());
if(user!=null){
session.setAttribute("user",user);
return "welcome";
}
return "login";
}
}
<settings>
<!--log4j配置引入-->
<setting name="logImpl" value="LOG4J"/>
</settings>
<!--设置别名-->
<typeAliases>
<!--全局设置别名:默认以类名作为别名-->
<package name="com.ssm.entity"/>
</typeAliases>
<!--mappers 代表小配置集合-->
<mappers>
<!--<mapper resource="org/mybatis/example/BlogMapper.xml"/>-->
<package name="com.ssm.dao"/>
</mappers>
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/test?useUniCode=true&characterEncoding=utf-8
jdbc.username=root
jdbc.password=root
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
手机扫一扫
移动阅读更方便
你可能感兴趣的文章