这是我的控制器:
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@Slf4j
@RestController
@RequestMapping("/auth-api")
public class AuthController {
@PostMapping("/register")
public RequestResultJSON<String> register(@RequestParam @NotEmpty String username,
@RequestParam @NotEmpty String password,
@RequestParam @NotEmpty String passwordConfirm);
我在我的 pom.xml 文件中使用了这个依赖项
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.0.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
当我发出发布请求时,我希望不会发生方法执行,但是会发生不正确的参数
请求:http://localhost:8080/auth-api/register?username&password&passwordConfirm
并使用 username=""、password=""、passwordConfirm="" 执行注册方法