Struts2 Wildcard Mapping - more specific one is being handled by generic one

前端 未结 1 1721
半阙折子戏
半阙折子戏 2020-12-19 20:27

I\'m currently playing around with my Struts2 config for wildcard testing and I\'m stuck with this one.

    

        
1条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-19 20:51

    You are using slashes in action name, that incorrectly works with wildcard mapper. As I said in the linked answer, the best pattern matcher in this case is the regex pattern matcher.

    
    

    See Advanced Wildcards.

    
        /WEB-INF/jsp/cmsPages/index.jsp
    
    
    
        /WEB-INF/jsp/cmsPages/templatePicker.jsp
    
    

    About docs for wildcard mapper. Lets look at the example blank application:

    
    
        
            /WEB-INF/jsp/example/HelloWorld.jsp
        
    
        
            /WEB-INF/jsp/example/Login.jsp
            Menu
        
    
        
            /WEB-INF/jsp/example/{1}.jsp
        
    
        
    
    

    So URLs will be matched in the order:

    1. http://localhost:8080/example/HelloWorld
    2. http://localhost:8080/example/Login_input
    3. http://localhost:8080/example/Register

    I would say that more specific mapping goes before less specific/common mapping and it wins because it's found first in the order of action configs. Everything that doesn't match the ordered configs fall into last mapping which is less specific.

    0 讨论(0)
提交回复
热议问题