jsp function tag to replace '

2019-06-09 11:29发布

Here is my code,

css/index.jsp:

<%@include file="/WEB-INF/common/css/common.jsp" %>
<style type="text/css">
    body{background: #ffffff url('<c:url value='/resources/images/logo/logo_small.png'/>') no-repeat scroll center center}
</style>

index.jsp page calls the above css/index.jsp page:

<c:set var="my_css">
    <c:if test="${branch == 'sitemap'}">
        <c:if test="${page == 'index'}">
            <%@include file="/WEB-INF/common/css/sitemap_common.jsp" %>
            <%@include file="/WEB-INF/common/css/index.jsp" %>
        </c:if>
    </c:if>
</c:set>
<c:set var="css" value='${fn:replace(fn:replace(fn:replace(my_css,"<style type=\\\"text/css\\\">", ""),"</style>", ""),"\'", "99999")}'/>
<compress:css enabled="true">
    <c:out value='${css}'/>
</compress:css>

In my project there are 100's of jsp pages that return css code. Why i'm doing this is to place my css as a link tag in head section.

In my code ' is replaced with 99999, but when i change 99999 to & #.. ; return & amp;#..; how to replace?

If there is a better option to convert my jsp to make it as a css link in html head section, please post here. You please post your suggestions too.

1条回答
狗以群分
2楼-- · 2019-06-09 11:38

now i need to modify for better performance

Modify the the css with some tool or maybe even with some simple java program before you upload it to the server. Then:

  • you do not need to spend time with this problem
  • the performance is much better (you do not need any replace stuff while runtime for every request)
查看更多
登录 后发表回答