开发者

Spring MVC URL Path Change

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜