0

​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>
fastcodejava
  • 39,895
  • 28
  • 133
  • 186
  • 1
    How have you configured your application to locate the *.jsp files? Can you please put in your resourcing configuration setup? – Aeseir May 13 '14 at 03:36

2 Answers2

2

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).

Stefan
  • 12,108
  • 5
  • 47
  • 66
1

/* 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.

ravi ranjan
  • 5,920
  • 2
  • 19
  • 18