Is there an JSTL EL (Expression Language) Equivalent to

后端 未结 3 977
没有蜡笔的小新
没有蜡笔的小新 2021-01-12 05:43

We use the tomcat urlrewrite plugin to rewrite outbound URLs as well as inbound ones. To do this, you need to use the JSTL tag.

This works great for clean urls and

3条回答
  •  情话喂你
    2021-01-12 06:29

    The solution I finally came up with was to use custom tags to solve the problem for CSS and JS. A similar solution could be applied to tags too of course, although I haven't had the need yet.

    
    
    

    The CSS tag looks like this, the Javascript one is obviously very similar:

    <%@tag language="java" pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    
    <%@attribute name="url" required="true" type="java.lang.String" description="the absolute (to the webapp) path of the css file"%>
    
    
    

    Don't forget to import the tags in your jsp:

    <%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>
    

    The custom EL solution would be cleaner is some circumstances, but if you want to add support for additional parameters or attributes, a tag is probably the way to go.

提交回复
热议问题