Reputation: 41117
If I try:
<servlet-mapping>
<servlet-name>app</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
I get this error:
No mapping found for HTTP request with URI [/sample/WEB-INF/jsp/person.jsp]
If I try just /
as <url-pattern>
then everything works fine.
My url : http://localhost:8080/sample/person
Why is this happening? What is the preferred way of doing this configuration in web.xml?
My app-servlet.xml
has :
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
Upvotes: 0
Views: 117
Reputation: 12462
You mapped /* (every request to your app) to your servlet called 'app'. The InternalResourceViewResolver than looks (internally) for '/person' inside '/WEB-INF/jsp/person.jsp'. This way you can access your views, while the scripts are secured inside WEB-INF, which is not accessible from the url (public).
Upvotes: 2
Reputation: 6129
/*
means every public request to your web-app. It means for your jsp it should be public accessed, since it is in WEB-INF and not public it will give error.
If you use only /
it means server took the request and the web-app processes it internal without any public access.
Upvotes: 1