[
https://issues.apache.org/jira/browse/SHIRO-873?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
wu updated SHIRO-873:
---------------------
Description:
Integration spring-boot-starter-web 2.6.5 and spring-boot-starter-validation
2.6.5
use "authc" filter.
{code:java}
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.Min;
@RestController
@RequestMapping("/test")
@Validated
public class TestController {
@PostMapping("/test")
public String test(@RequestParam @Min(10) Integer i){
return "test";
}
}
{code}
When annotation @Validated on TestController, link "/test/test" is return to
"404 not found"
If don't ues annotation @Validated, link mapping is right, but annotation
@Min(10) to validate is not work.
------------------------------------------ updateline
----------------------------------------
Well , I tracked the code for creating bean instances of the spring framework.
The bean instances of TestController is of type 'jdk.proxy2.$Proxy92', Why?
Just use The annotation "Validated".
Because of bean is of type 'jdk.proxy2.$Proxy92' , RequestMappingHandler will
not load this controller.
It's puzzling
please check it, thanks.
was:
Integration spring-boot-starter-web 2.6.5 and spring-boot-starter-validation
2.6.5
use "authc" filter.
{code:java}
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.Min;
@RestController
@RequestMapping("/test")
@Validated
public class TestController {
@PostMapping("/test")
public String test(@RequestParam @Min(10) Integer i){
return "test";
}
}
{code}
When annotation @Validated on TestController, link "/test/test" is return to
"404 not found"
If don't ues annotation @Validated, link mapping is right, but annotation
@Min(10) to validate is not work.
if use '@RequestBody' and '@Validated' on method parameter , it's worked..
like this
{code:java}
import javax.validation.constraints.Min;
public class User{
@Min(10)
Integer id;
} {code}
{code:java}
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.validation.annotation.Validated;
@RestController
@RequestMapping("/test1")
public class Test1Controller{
@PostMapping("/test1")
public String test1(@Request @Validated User user) {
return "test1"
}
}
{code}
-------------------------------------------update
line----------------------------------
Well , I tracked the code for creating bean instances of the spring framework.
The bean instances of TestController is of type 'jdk.proxy2.$Proxy92', Why?
Just use The annotation "Validated".
Because of bean is of type 'jdk.proxy2.$Proxy92' , RequestMappingHandler will
not load this controller.
It's puzzling
please check it, thanks.
> Return to "404 not found" when controller uses annotation "@Validated".
> -----------------------------------------------------------------------
>
> Key: SHIRO-873
> URL: https://issues.apache.org/jira/browse/SHIRO-873
> Project: Shiro
> Issue Type: Bug
> Components: Integration: Spring
> Affects Versions: 1.9.0
> Environment: OS: macos12.3
> JDK: openjdk version "17.0.2" 2022-01-18 LTS
> spring-boot-starter-web: 2.6.5
> spring-boot-starter-validation: 2.6.5
> shiro: 1.9.0
> Reporter: wu
> Assignee: Les Hazlewood
> Priority: Major
>
> Integration spring-boot-starter-web 2.6.5 and spring-boot-starter-validation
> 2.6.5
>
> use "authc" filter.
>
>
> {code:java}
> import org.springframework.web.bind.annotation.RestController;
> import org.springframework.web.bind.annotation.RequestMapping;
> import org.springframework.web.bind.annotation.PostMapping;
> import org.springframework.validation.annotation.Validated;
> import javax.validation.constraints.Min;
> @RestController
> @RequestMapping("/test")
> @Validated
> public class TestController {
> @PostMapping("/test")
> public String test(@RequestParam @Min(10) Integer i){
> return "test";
> }
> }
> {code}
> When annotation @Validated on TestController, link "/test/test" is return to
> "404 not found"
> If don't ues annotation @Validated, link mapping is right, but annotation
> @Min(10) to validate is not work.
>
> ------------------------------------------ updateline
> ----------------------------------------
> Well , I tracked the code for creating bean instances of the spring
> framework.
> The bean instances of TestController is of type 'jdk.proxy2.$Proxy92', Why?
> Just use The annotation "Validated".
> Because of bean is of type 'jdk.proxy2.$Proxy92' , RequestMappingHandler
> will not load this controller.
> It's puzzling
> please check it, thanks.
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]