I read over this post, which is similar to my issue, but had no luck solving the problem:
Basically I used to have the following servlet-mapping in my web.xml
:
<servlet-mapping>
<servlet-name>myServlet</servlet-name>
<url-pattern>/index.html</url-pattern>
<url-pattern>/channel1</url-pattern>
<url-pattern>/channel2</url-pattern>
</servlet-mapping>
This worked perfectly until I needed to map the following url:
/channel1/{id}/{random_text}
Where {id} is a numeric ID value of my objects and {random_text} is just there just for "freindly urls". I managed to get this to work using the @RequestMapping
in my controller as well as the @PathVariable
to pull the variables from the URL.
However, the only way I managed to get the new URL to map successfully is be adding
<url-pattern>/</url-pattern>
to my web.xml
at the bottom of my servlet-mappings. BUT, when I do this, all my other pages (/channel1
, /channel2
) display without access to the static content (css, jsp etc); I get a No mapping found for HTTP request with URI
for the static files. I tried various combinations of mappings as suggested in the link I posted, but nothing worked. Any help would be great!!!
Update: my RequestMapping in the controller looks as follows (if it helps solve the problem at all..):
@RequestMapping(value = { "/channel1/{id}", "/channel1/{id}/{text}" })