3

ここに web.xml の url-pattern があります

<servlet-mapping>  
<servlet-name>dispatcher</servlet-name>  
<url-pattern>/</url-pattern>  
</servlet-mapping>  

これが私のコントローラーです

@Controller  
public class HelloController   
{  
        @RequestMapping("/*.km")  
    public String handleKm()  
    {  
        System.out.println("km ext called");  
        return "aaa";  
    }  

    @RequestMapping("/*.jsp")  
    public String handleJsp()  
    {  
        System.out.println("jsp pages called");  
        return "bbb";  
    }  
}  

/requestMapping/a.km で URL にアクセスしている間、動作し、handleKm() メソッドを呼び出します。しかし、/requestMapping/a.jsp では、handleJsp() を呼び出す必要がありますが、動作しません。結果: HTTP ステータス 404 - /requestMapping/a.jsp。どうして ??

URLパターンを「/」から「/*」に変更すると、両方のメソッドが呼び出されますが、適切なページに到達しません。「org.springframework.web.servlet.view.InternalResourceViewResolver」が機能していない可能性があります。

4

1 に答える 1

0

Check out this related SO post (possibly a duplicate). I think the .jsp extension is confusing the dispatcher servlet. Try using an extension that isn't .jsp and see if that works.

于 2013-07-25T04:59:18.503 に答える