java - Basic Spring MVC config: PageNotFound using InternalResourceViewResolver -
i'm trying first spring 3 mvc setup running.
my app running on tomcat, in server context of "grapevine"
for purposes of testing, i'm trying requests http://localhost:8080/grapevine/test
render contents of web-inf/jsp/nosuchinvitation.jsp
when try this, i'm getting 404
, , logs suggest jsp isn't present:
warn org.springframework.web.servlet.pagenotfound - no mapping found http request uri [/grapevine/web-inf/jsp/nosuchinvitation.jsp] in dispatcherservlet name 'grapevine'
i must have mis-configured somewhere, can't see i've done wrong.
here's relevant snippets.
web.xml:
<servlet> <servlet-name>grapevine</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>grapevine</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping>
from context:
<mvc:annotation-driven /> <bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix" value="/web-inf/jsp/"/> <property name="suffix" value=".jsp"/> </bean>
controller:
@controller public class participantinvitationcontroller { @requestmapping("/test") public modelandview test() { return new modelandview("nosuchinvitation"); }
log:
debug org.springframework.web.servlet.dispatcherservlet - rendering view [org.springframework.web.servlet.view.jstlview: name 'nosuchinvitation'; url [/web-inf/jsp/nosuchinvitation.jsp]] in dispatcherservlet name 'grapevine' debug org.springframework.web.servlet.view.jstlview - forwarding resource [/web-inf/jsp/nosuchinvitation.jsp] in internalresourceview 'nosuchinvitation' debug org.springframework.web.servlet.dispatcherservlet - dispatcherservlet name 'grapevine' processing request [/grapevine/web-inf/jsp/nosuchinvitation.jsp] warn org.springframework.web.servlet.pagenotfound - no mapping found http request uri [/grapevine/web-inf/jsp/nosuchinvitation.jsp] in dispatcherservlet name 'grapevine' debug org.springframework.security.web.context.httpsessionsecuritycontextrepository - securitycontext contents anonymous - context not stored in httpsession. debug org.springframework.web.servlet.dispatcherservlet - completed request
this because <url-pattern>
in web.xml
"wide". value of /*
means servlet configured receive requests, , includes request servlet jsp. error message you're seeing dispatcherservlet
, receiving own forwarded request.
you should pick more specific <url-pattern>
, e.g. <url-pattern>/xyz/*</url-pattern>
, url becomes http://localhost:8080/grapevine/xyz/test
, , should work fine.
Comments
Post a Comment