You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@shiro.apache.org by "wu (Jira)" <ji...@apache.org> on 2022/04/01 01:39:00 UTC

[jira] [Commented] (SHIRO-873) Return to "404 not found" when controller uses annotation "@Validated".

    [ https://issues.apache.org/jira/browse/SHIRO-873?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17515659#comment-17515659 ] 

wu commented on SHIRO-873:
--------------------------

[~bdemers]  

Hi, there is the code.

[https://github.com/wzh90/shiro_404.git]

1.  just login (/anon/login)

2. URL: /authc/test  has a param "age",  it’s return 404.

3. URL: /none/test  is contrast without shiro it’s worked. (validate age greater than 10)

 

 

 

 

> 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
>  
> ------------------------------------------   updateline2  ----------------------------------------
> Did some research, I found "Validated" make spring use dynamic proxy to the bean and spring use AnnotatedElementUtils to check super class annotation. So what did shiro do ?
> please check it, thanks.
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@shiro.apache.org
For additional commands, e-mail: issues-help@shiro.apache.org