有一个服务器,在输入登录名和密码时,会返回一个状态200 Ok
。我还需要它以响应正确的登录名和密码,响应将以表单形式出现,JSON
例如,字段data
。我该怎么做?这是 SpringSecurity 本身:
@Override
protected void configure(final HttpSecurity http) throws Exception {
http
.cors()
.and()
.authorizeRequests()
.anyRequest().authenticated()
.and()
.exceptionHandling()
.authenticationEntryPoint((req, res, e) -> res.setStatus(401))
.and()
.formLogin()
.successHandler((req, res, e) -> res.setStatus(200))
.failureHandler((req, res, e) -> res.setStatus(401))
.and()
.csrf().disable();
}
EMNIP,res是HttpServletResponse,所以可以这样试试