开发者

Use JSTL tags in GSP

I'm trying to use the c:url JSTL tag in a GSP. I've added the following declaration to the top of the GSP's layout:

<%@ taglib uri="http://java.su开发者_开发问答n.com/jsp/jstl/core" prefix="c" %>

I've also added jstl-1.1.2.jar as a depenency. When I call this tag in a GSP:

${c.url(value: 'j_spring_security_check')}

I get the error:

Error evaluating expression [c.url(value: 'j_spring_security_check')] on line [27]: Cannot invoke method url() on null object

According to the Grails docs, the method-style of tag invocation should is supported for JSP tags, so I don't think this is the problem. Do I need to include the JSTL taglib's TLD somewhere in the Grails app in order for this to work?


It turns out that the problem was this declaration:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

For some reason it doesn't work if it's added to the layout, it must appear in the GSP itself. The .tld for the taglib magically appears in /web-app/WEB-INF/tld when the dependency on the taglib's JAR is added to BuildConfig.groovy

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜