将 JSP 参数传递给 spring 控制器

发布于 2024-11-28 05:53:45 字数 839 浏览 2 评论 0原文

我在 jsp 到控制器之间传递值时遇到问题..

我的 home.jsp 包含另一个文件 check.jsp..

<jsp:include page="check.html" flush="true">
    <jsp:param name="param1" value="1" />
    <jsp:param name="param2" value="expert" />
    <jsp:param name="param3" value="skill"/>
</jsp:include>

这是控制器...

@RequestMapping(value="check", method = RequestMethod.GET)
public String checkList(ModelMap modelMap, HttpServletRequest request){
    Map<String, String> map = new HashMap<String, String>();
    map.put("param1",request.getParameter("param1"));
    map.put("param2",request.getParameter("param2"));
    map.put("param3",request.getParameter("param3"));
    modelMap.addAllAttributes(map);
    return "checklist";
}

但我无法获取控制器中的值..我的意思是所有参数值控制器中为空。如何获取这些值?

I am having issues with passing values between jsp to controller..

my home.jsp includes another file check.jsp..

<jsp:include page="check.html" flush="true">
    <jsp:param name="param1" value="1" />
    <jsp:param name="param2" value="expert" />
    <jsp:param name="param3" value="skill"/>
</jsp:include>

and here is the controller...

@RequestMapping(value="check", method = RequestMethod.GET)
public String checkList(ModelMap modelMap, HttpServletRequest request){
    Map<String, String> map = new HashMap<String, String>();
    map.put("param1",request.getParameter("param1"));
    map.put("param2",request.getParameter("param2"));
    map.put("param3",request.getParameter("param3"));
    modelMap.addAllAttributes(map);
    return "checklist";
}

but I can't get the values in controller.. I mean all param values are null in the controller.. How to get these values?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷爱 2024-12-05 05:53:45
  1. check != check.html
  2. include != GET

这就是你的参数为空的原因。

  1. check != check.html
  2. include != GET

That's why your params are empty.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文