使用Spring JSTL和Spring表单标签一起

3
在Spring MVC应用程序中的jsp页面中,是否可以混合使用jstl标签和spring表单标签?
<form:form method="POST" action="<c:url value='/j_spring_security_check'/>">
    code
</form:form>

输出结果为:
<form method="POST" action="<c:url value='/j_spring_security_check'/>">
    code
</form>

Spring标签得到解析,但JSTL标签没有被解析。我不知道我做错了什么。


你看到的输出是什么? - gowtham
你在JSP中添加了JSTL核心标签吗? - Keerthivasan
请查看更新@Octopus - h-rai
请发布错误堆栈跟踪。 - Keerthivasan
没有堆栈跟踪。 action属性的值未按预期解析。 @Octopus - h-rai
@nick-s 你试过我的答案了吗?请告诉我发生了什么。 - Keerthivasan
2个回答

7

根据被采纳的答案,我们不应该混合使用c:url标签和spring表单标签,这是非法的。相反,您应该按照以下方式处理:

链接
<c:url value="/j_spring_security_check" var="theAction"/>
<form:form method="POST" action="${theAction}">
code
</form:form>

0
请确保在您的JSP中添加taglib。
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

希望你只添加了下面的spring-form标签库。
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接