Spring MVC,表单动作中的子文件夹

发布于 2025-01-06 16:59:47 字数 1112 浏览 1 评论 0原文

我有问题,如何在操作属性中创建 uri。我必须使用子文件夹作为“用户”、“管理员”,因为我使用 Spring Security。

<form:form action="/user/reservationTour.html" method="post" commandName="bookTourForm">

结果,无项目名称 http://localhost:8080/user/reservationTour.html

<form:form action="user/reservationTour.html" method="post" commandName="bookTourForm">

结果,2x链接中的用户 http://localhost:8080/ProjectContextTitle/user/user/reservationTour.html

<form:form action="<c:url value="/user/reservationTour.html" />" method="post" commandName="bookTourForm">

结果,异常

org.apache.jasper.JasperException: /jsp/user/reservationTourPage.jsp(7,33) Unterminated &lt;form:form tag

这工作正常,但肯定不是一个好的解决方案

<form:form action="/ProjectContextName/user/reservationTour.html" method="post" commandName="bookTourForm">

I have problem, how to create uri in action attribute. I have to use subfolders as "user", "admin" because I use Spring Security.

<form:form action="/user/reservationTour.html" method="post" commandName="bookTourForm">

Result, no project name http://localhost:8080/user/reservationTour.html

<form:form action="user/reservationTour.html" method="post" commandName="bookTourForm">

Result, 2x user in link http://localhost:8080/ProjectContextTitle/user/user/reservationTour.html

<form:form action="<c:url value="/user/reservationTour.html" />" method="post" commandName="bookTourForm">

Result, exception

org.apache.jasper.JasperException: /jsp/user/reservationTourPage.jsp(7,33) Unterminated <form:form tag

This works fine, but sure not good solution

<form:form action="/ProjectContextName/user/reservationTour.html" method="post" commandName="bookTourForm">

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

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

发布评论

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

评论(1

茶底世界 2025-01-13 16:59:47

如果您已经在用户目录中,则只需使用相对 URL:

<form:form action="reservationTour.html" method="post" commandName="bookTourForm">

如果您想使用绝对 URL,请使用 ,但不要将其包含在另一个 JSP 标记的属性:这是非法的。

<c:url value="/user/reservationTour.html" var="theAction"/>
<form:form action="${theAction}" ...>

If you're already in the user directory, you just need to use a relative URL:

<form:form action="reservationTour.html" method="post" commandName="bookTourForm">

If you want to use an absolute URL, use <c:url>, but don't include it in the attribute of another JSP tag: that's illegal.

<c:url value="/user/reservationTour.html" var="theAction"/>
<form:form action="${theAction}" ...>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文