java - spring boot framework uses restful to verify whether the username exists
女神的闺蜜爱上我
女神的闺蜜爱上我 2017-06-28 09:25:42
0
2
1089

When using restful style to verify whether the user name exists, all normal names can be verified, but when verifying whether the email address exists, no parameters can be accepted. The code is as follows

@ApiOperation(value = "查询用户名是否存在", notes = "查询用户名是否存在") @GetMapping("/check/{userName}") public BaseResult checkUserName(@PathVariable("userName") String userName) { return appUserService.checkUserName(userName); }

The following are test pictures

女神的闺蜜爱上我
女神的闺蜜爱上我

reply all (2)
typecho

Need to modify the default url matching rules of spring boot

@Override public void configurePathMatch(PathMatchConfigurer configurer) { configurer.setUseSuffixPatternMatch(false); }

configurer.setUseSuffixPatternMatch(false) means that the URL exposed by the system will not recognize and match the .* suffix.

In this code, it means that Spring will pass sunny.cn to the Controller as a {userName} parameter.

    过去多啦不再A梦

    You can also use expressions

    @RequestMapping(value = "/{userName:.+}",method = RequestMethod.GET) public String query(@PathVariable("userName") String userName){ return username; }
      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!