show databases;
drop database if exists mydemo;
create database mydemo;
use mydemo;
create table userinfos(
userid int primary key not null auto_increment,
username varchar(20) not null,
birthday date not null);
show tables;
insert into userinfos(username,birthday) values ('aaa','1996-9-9');
insert into userinfos(username,birthday) values('bbb','1996-9-9');
select * from userinfos;
package com.kgc.ssmdemo2.entity;
import java.io.Serializable;
import java.util.Date;
public class Userinfos implements Serializable {
private int userid;
private String username;
private Date birthday;
public int getUserid() {
return userid;
}
public void setUserid(int userid) {
this.userid = userid;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
}
dao 接口
package com.kgc.ssmdemo5.dao;
import com.kgc.ssmdemo5.entity.User;
import org.apache.ibatis.annotations.*;
import java.util.List;
public interface UserDAO {
@Insert("insert into userinfos(username,birthday) values (#{username},#{birthday}) ")
public void insertUser(User user);
@Delete("delete from userinfos where userid=#{userid}")
public void delUser(@Param("userid") int userid);
@Update("update userinfos set username=#{username},birthday=#{birthday} where userid=#{userid}")
public void modUser(User user);
@Select("select * from userinfos")
public List findAll();
@Select("select * from userinfos where userid=#{userid}")
public User findById(@Param("userid") int userid);
}
Archetype Created Web ApplicationcontextConfigLocationclasspath:spring.xmlcharsetorg.springframework.web.filter.CharacterEncodingFilterencodingutf-8charset/*org.springframework.web.context.ContextLoaderListenerspringorg.springframework.web.servlet.DispatcherServletcontextConfigLocationclasspath:spring.xmlspring*.do
index.jsp
留意这里注释掉的地方,掌握这些小技巧,40分钟不是梦!
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
Created by IntelliJ IDEA.
User: mu_bai
Date: 2019/11/13
Time: 22:12
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
Title
<%--div.header>a[href='save.jsp']{创建新用户} 打完按tab键,感受快乐--%>
<%--
Created by IntelliJ IDEA.
User: mu_bai
Date: 2019/11/13
Time: 22:27
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
Title
<%--div.ctx>form[action='save.do' method='post']>(label{用户}+input[type='text' name='']+br)*3--%>
user.jsp
<%--
Created by IntelliJ IDEA.
User: mu_bai
Date: 2019/11/13
Time: 23:19
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false"%>
Title