@RestController
public class NewStudentController {
@PostMapping("/new-students")
public ResponseEntity
// 处理添加新学生的逻辑
return ResponseEntity.ok("学生已成功添加");
}
}
]]>
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests()
.antMatchers("/new-students").permitAll()
.anyRequest().authenticated()
.and()
.httpBasic();
}
}
]]>