Skip to content

Commit 6154dd9

Browse files
committed
mybatis
1 parent e493d25 commit 6154dd9

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

spring-boot-mybatis/spring-boot-mybatis-annotation/src/main/java/com/neo/web/UserController.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import org.springframework.web.bind.annotation.PathVariable;
77
import org.springframework.web.bind.annotation.RequestMapping;
88
import org.springframework.web.bind.annotation.RestController;
9-
9+
import org.springframework.web.bind.annotation.RequestMethod;
1010
import com.neo.model.User;
1111
import com.neo.mapper.UserMapper;
1212

@@ -27,21 +27,19 @@ public User getUser(Long id) {
2727
User user=userMapper.getOne(id);
2828
return user;
2929
}
30-
31-
@RequestMapping("/add")
30+
31+
@RequestMapping(value = "/add", method = RequestMethod.POST)
3232
public void save(User user) {
33-
userMapper.insert(user);
33+
userMapper.insert(user);
3434
}
35-
35+
3636
@RequestMapping(value="update")
3737
public void update(User user) {
3838
userMapper.update(user);
3939
}
40-
40+
4141
@RequestMapping(value="/delete/{id}")
4242
public void delete(@PathVariable("id") Long id) {
4343
userMapper.delete(id);
4444
}
45-
46-
4745
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mybatis.type-aliases-package=com.neo.model
2-
2+
server.port=9090
33
spring.datasource.url=jdbc:mysql://localhost:3306/test?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true
44
spring.datasource.username=root
5-
spring.datasource.password=root
5+
spring.datasource.password=123456
66
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

spring-boot-web/src/main/java/com/neo/web/ThymeleafController.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ public class ThymeleafController {
1414
@RequestMapping("/hi")
1515
public String hello(Locale locale, Model model) {
1616
model.addAttribute("greeting", "Hello!");
17-
1817
Date date = new Date();
1918
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
2019
String formattedDate = dateFormat.format(date);
2120
model.addAttribute("currentTime", formattedDate);
22-
2321
return "hello";
2422
}
2523

0 commit comments

Comments
 (0)