开发者

EL inside form:input causes unclosed tag error

When I try to do things like <c:if ...>...</c:if> inside a form:input tag I get the err开发者_C百科or in my console that the form:input has not been closed.

Does anyone have an idea why this happens, and the cleanest solution? (maybe a set var and then ${result of c:if})


You can not use <c:if> this way:

<form:input type="text" ... <c:if test="${empty bla}">disabled="disabled"</c:if>/>

In your case you have to write:

<form:input type="text" ... disabled="${empty bla}" />

(Pay attention to a related bug fixed in Spring 3.0.1 https://jira.springframework.org/browse/SPR-6790)

 


JSP tags, unlike HTML tags, have a special meaning in JSP syntax, therefore you can't use EL expressions in arbitrary places of JSP tags. EL expressions can only be used in their attributes, so you need something like this (note that name and id are not needed, they are inferred from path):

<form:input path="x" title="x(dd/MM/yyyy)" maxlength="10" size="10" 
    class = "${(empty eee) ? 'date' : ''}" 
    disabled = "${(not empty ccc) ? 'true' : 'false'}" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜