Skip to content

Commit 4ab6c40

Browse files
committed
1 parent d89257f commit 4ab6c40

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

help/validator-requests.http

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@ GET http://localhost:9100/validator/validateValue
1515

1616
### /validator/user
1717
GET http://localhost:9100/validator/user?name=a
18+
19+
### /validator/validated/register
20+
POST http://localhost:9100/validator/validated/register
21+
Content-Type: application/x-www-form-urlencoded
22+
23+
#username=a&password=bbbbbb
24+
username=a&password=b
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package cn.netbuffer.springboot.demo.controller;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.springframework.http.ResponseEntity;
5+
import org.springframework.validation.annotation.Validated;
6+
import org.springframework.web.bind.annotation.PostMapping;
7+
import org.springframework.web.bind.annotation.RequestMapping;
8+
import org.springframework.web.bind.annotation.RestController;
9+
import javax.validation.constraints.NotBlank;
10+
import javax.validation.constraints.Size;
11+
12+
@Slf4j
13+
@Validated
14+
@RestController
15+
@RequestMapping("/validator/validated")
16+
public class ValidatorValidatedTestController {
17+
18+
19+
@PostMapping("/register")
20+
public ResponseEntity<String> registerUser(@NotBlank(message = "用户名不能为空") String username,
21+
@Size(min = 6, message = "密码长度不能少于6位") String password) {
22+
log.debug("receive username={} password={}", username, password);
23+
return ResponseEntity.ok("注册成功-" + username);
24+
}
25+
26+
}

0 commit comments

Comments
 (0)