【发布时间】:2017-07-07 05:14:23
【问题描述】:
我想在我的 Spring MVC 中添加一个页面。我可以调用索引文件,但我无法单击index.jsp 中的链接以显示页面product.jsp。它的错误消息是“请求的资源不可用”。
下面是我的控制器代码:
@RequestMapping({"/", "/index"})
public String index(ModelMap model, HttpSession session, Principal principal) throws Exception {
return "index";
}
@RequestMapping({"/product"})
public String product(ModelMap model, HttpSession session, Principal principal) throws Exception {
return "product";
}
这个 index.jsp
<div class="row">
<div class="col-sm-4 menu-img-pad">
<ul class="multi-column-dropdown">
<li><a href="../product.jsp">Joggers</a></li>
<li><a href="../product.jsp">Foot Ball</a></li>
<li><a href="../product.jsp">Cricket</a></li>
</ul>
</div>
</div>
【问题讨论】:
-
试试这个:
<a href="/product">Joggers</a> -
提供 product.jsp 的绝对路径或将文件(index.jsp 和 product.jsp )保存在同一个文件夹中。
-
@Aamir >Folder>index.jsp 和 product 和 Folder 一样在同一个位置。
-
@Càphêđen 它不起作用。
标签: java spring jsp spring-mvc