spring-mvc

Spring MVC complex object data binding

大憨熊 提交于 2020-02-05 03:44:05
问题 I am still struggling with Spring MVC with what should be a fairly straightforward problem but what seems to be sparsly documented in Spring MVC documentation. My project uses Spring MVC and Thymeleaf for the views, but the view rendering engine is not really relevant to the problem. My application is centered around an Activity class which models an (indoor or outdoor) activity which is organized by a member and where fellow members can subscribe to. An Activity has, among others, a Category

Using Java config with Spring Security for annotation-based role checks and Basic HTTP Auth

假装没事ソ 提交于 2020-02-04 06:00:40
问题 I'm trying to accomplish annotation-based (using @PreAuthorize ) permission checking on one of my controllers. I'm using Java config, and have a SecurityConfig class extending WebSecurityConfigurerAdapter . I'm also using Basic HTTP Authentication to get to the methods that require authorization. But - the problem is, I don't want the SecurityConfig determining which methods require authentication using an antPattern() or similar. That's what the annotations are for! How can I configure my

Using Java config with Spring Security for annotation-based role checks and Basic HTTP Auth

空扰寡人 提交于 2020-02-04 05:59:33
问题 I'm trying to accomplish annotation-based (using @PreAuthorize ) permission checking on one of my controllers. I'm using Java config, and have a SecurityConfig class extending WebSecurityConfigurerAdapter . I'm also using Basic HTTP Authentication to get to the methods that require authorization. But - the problem is, I don't want the SecurityConfig determining which methods require authentication using an antPattern() or similar. That's what the annotations are for! How can I configure my

Spring Security (3.2.5) HTTP POST not forwarding to the original request after authentication

纵饮孤独 提交于 2020-02-03 18:58:46
问题 I have a sample Spring MVC application, secured by Spring security (Spring version 4.0.1.RELEASE, Spring security 3.2.5.RELEASE. When I send an HTTP GET request as an unauthenticated user, I am sent to the login page (as expected) where after I authenticate I am sent along to the page that was requested in the original GET. When I send an HTTP POST request as an unauthenticated user, I am sent to the login page (as expected), but then after successful authentication I am sent to the page as

Spring Security (3.2.5) HTTP POST not forwarding to the original request after authentication

六月ゝ 毕业季﹏ 提交于 2020-02-03 18:58:01
问题 I have a sample Spring MVC application, secured by Spring security (Spring version 4.0.1.RELEASE, Spring security 3.2.5.RELEASE. When I send an HTTP GET request as an unauthenticated user, I am sent to the login page (as expected) where after I authenticate I am sent along to the page that was requested in the original GET. When I send an HTTP POST request as an unauthenticated user, I am sent to the login page (as expected), but then after successful authentication I am sent to the page as

Spring Security (3.2.5) HTTP POST not forwarding to the original request after authentication

人盡茶涼 提交于 2020-02-03 18:57:26
问题 I have a sample Spring MVC application, secured by Spring security (Spring version 4.0.1.RELEASE, Spring security 3.2.5.RELEASE. When I send an HTTP GET request as an unauthenticated user, I am sent to the login page (as expected) where after I authenticate I am sent along to the page that was requested in the original GET. When I send an HTTP POST request as an unauthenticated user, I am sent to the login page (as expected), but then after successful authentication I am sent to the page as

Spring Security (3.2.5) HTTP POST not forwarding to the original request after authentication

扶醉桌前 提交于 2020-02-03 18:57:11
问题 I have a sample Spring MVC application, secured by Spring security (Spring version 4.0.1.RELEASE, Spring security 3.2.5.RELEASE. When I send an HTTP GET request as an unauthenticated user, I am sent to the login page (as expected) where after I authenticate I am sent along to the page that was requested in the original GET. When I send an HTTP POST request as an unauthenticated user, I am sent to the login page (as expected), but then after successful authentication I am sent to the page as

I/O error while reading input message; nested exception is java.io.IOException: Stream closed

依然范特西╮ 提交于 2020-02-03 09:59:35
问题 @RestController @RequestMapping("/reclamacao") public class ClaimController { @Autowired private ClaimRepository claimRepository; @CrossOrigin @PostMapping("/adicionar") public Claim toCreateClaim(@Valid @RequestBody Claim claim, @RequestBody List<Sector> sectors) { if (claim.getNumber() != null) { if (claimRepository.findByNumber(claim.getNumber()).isPresent()) { throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Já existe uma reclamação com esse número."); } } claimRepository.save

I/O error while reading input message; nested exception is java.io.IOException: Stream closed

♀尐吖头ヾ 提交于 2020-02-03 09:58:06
问题 @RestController @RequestMapping("/reclamacao") public class ClaimController { @Autowired private ClaimRepository claimRepository; @CrossOrigin @PostMapping("/adicionar") public Claim toCreateClaim(@Valid @RequestBody Claim claim, @RequestBody List<Sector> sectors) { if (claim.getNumber() != null) { if (claimRepository.findByNumber(claim.getNumber()).isPresent()) { throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Já existe uma reclamação com esse número."); } } claimRepository.save

Getting value of invalid field after MethodArgumentNotValidException

家住魔仙堡 提交于 2020-02-03 08:44:49
问题 My entity class is annotated with @NotNull of hibernate for one of the field.I am catching the exception in @ExceptionHelper . My problem is that i want to access the value of the invalid field so that i can add it into the logger. Here is the ExceptionHandler : @ExceptionHandler({ MethodArgumentNotValidException .class }) @ResponseBody public ResponseEntity<?> handleInvalidMethodArgException(MethodArgumentNotValidException de) { List<FieldError> bindingResult = de.getBindingResult()