【发布时间】:2020-08-18 04:51:52
【问题描述】:
正如您所见,我在请求映射中的问候正在返回“欢迎”jsp 页面,但如果我想在欢迎 jsp 页面中使用“a href”来调用查看 jsp 页面,我应该调用控制器请求映射,即“/products”或应该直接调用viewtable jsp页面吗?
welcome.jsp
< a href="??"</ahref>
viewtable.jsp
<h1>hellow<h1>
控制器
@RequestMapping(value="/hellow",method = RequestMethod.GET) public String
abc(ModelMap model) { return "welcome"; }
@RequestMapping(value="/products", method= RequestMethod.GET)
public String getAllProducts(ModelMap model)
{
System.out.println("in controller");
//return pls.productListAllRecords();
List display;
display=productservice.listAllRecords();
System.out.println(display);
model.addAttribute("records",display);
// return "viewtable";
return "viewtable";
}
【问题讨论】:
-
你应该在welcome.jsp中写java脚本代码,例如:``` ```
标签: java spring spring-boot model-view-controller