我想知道在springboot web应用程序中,当我们从一个jsp重定向到另一个jsp时



正如您所看到的,我在请求映射中的hellow正在返回"欢迎";jsp页面,但是如果我想使用";a href"在欢迎jsp页面调用视图jsp页面时,我应该调用控制器requestmapping ie"/产品";还是应该直接调用viewtablejsp页面?

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";
}

如果您想将用户引导到相应的页面,可以在"lt;a>quot;标记,其中包含requestMapping路径。

选择后,以下路径将指向上述两个路径。

<a href="/hellow">Hellow</a>
<a href="/products">Products</a>

相关内容

最新更新