views:

33

answers:

1

Hi All,

I am new to web programming and Spring MVC 2.5.

I am not sure about my problem is spring sprecific or web specific in general.

I have a menu.jsp and I use jsp:include to include it in all my jsp.

<ul class="menu">
    <c:url var="home" value="home.htm"/>
    <c:url var="data" value="data.htm"/>

    <li><a href="${home}" class="parent"><span>HOME</span></a></li>
    <li><a href="${data}" class="parent"><span>DATA</span></a></li>
</ul>

When I hit my app the first time and calls http://localhost:8080/myapp/home.htm, everything went fine. But when I click a link that brought me to a new url using multiactioncontroller.

@RequestMapping(value = "/epm/epmItemList.htm", method = RequestMethod.GET)
public String setupForm(Model model, HttpServletResponse response) throws IOException {

}
@RequestMapping(value = "/epm/epmdelete.htm", method = RequestMethod.GET)
public String setupForm(Model model, HttpServletResponse response) throws IOException {

}

And then I click, home again. I am getting a 404. I am not sure why, but when I check the link at my url it now it becomes: http://localhost:8080/myapp/epm/home.htm

Spring is naturally saying no handler mapping can be found since I did not configure any mapping for these. How can I fix this problem? Thanks

A: 

Try the following change :

<ul class="menu">
    <c:url var="home" value="/home.htm"/>
    <c:url var="data" value="/data.htm"/>

    <li><a href="${home}" class="parent"><span>HOME</span></a></li>
    <li><a href="${data}" class="parent"><span>DATA</span></a></li>
</ul>

This way the links should be relative to your context and not relative to the local page.

Timo Westkämper
@Timo Westkamper.. that did the trick. Thank you =)
Mark Estrada
@Mark Estrada, consider upvoting the answer because you found it to be correct.
ponzao