JSTL 到 CSS 文件中



我有 3 个 jsp:

  • template_blank.jsp
  • template_connected.jsp
  • 模板.jsp

这个 jsp 调用一个 css 文件 --> commun.css

这是模板中的调用.jsp例如:

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html:base ref="site"/>
<html:html>
    <head>
        <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <tiles:useAttribute id="title" name="title"/>
        <title><bean:message key="${title}"/></title>   
        <link rel="stylesheet" type="text/css" href="<html:rewrite page="/css/commun.css"/>">
        <link rel="icon" type="image/png" href="images/icone.ico" />
        <script type="text/javascript" src="<html:rewrite page="/javascript/commun.js" />" ></script>
        <!-- Start of user code for header -->
        <jsp:include page="/javascript/generic/messages.jsp"/> 
        <!-- End of user code for header -->
    </head>
    <body>
....

这是我的社区.css

/* Start of user code for commun.css */
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<c:set var="headerHeight" value="156" />
<c:set var="footerHeight" value="0" /> /* 95 */
<c:set var="menuWidth" value="180" />
<c:if test="${height == null}">
    <c:set var="height" value="500" />
</c:if>
<c:if test="${width == null}">
    <c:set var="width" value="500" />
</c:if>
<c:set var="contentHeight" value="${height - footerHeight - headerHeight}" />
<c:set var="contentWidth" value="${width}" />
<c:set var="contentWidthConnected" value="${width - menuWidth}" />
<c:set var="tabHeight" value="27" />
<c:set var="contentHeightWithTab" value="${contentHeight - tabHeight - 1}" />
div#errors UL {
    background-color: yellow;
    color: red;
    border: 1px dotted red;
    padding: 5px;
    padding-left: 20px;
    margin-left: 20px;
    margin-right: 20px;
    font-size: 10px;
}
.fontAlerte {
    color: #006039;
    font-size: 11px;
}
.field_error {
    background-color: yellow;
    border: 1px dotted red;
}
....

你可以在我的css中看到JSTL。它用于定义不同的heightwidth。问题是 css 是在 html 显示之后执行的。

所以我有一个显示问题,每次调用新页面都会产生闪烁效果。是否有可能改善这种行为?

您的排序似乎不对。我不清楚什么是 JSP 以及什么是 JS 内容,但足以说明您应该尽可能长时间地尝试延迟 JS 加载(即等到您的

标签结束之前)。

<html:base ref="site"/>
<html:html>
    <head>
        <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <tiles:useAttribute id="title" name="title"/>
        <title><bean:message key="${title}"/></title>   
        <link rel="stylesheet" type="text/css" href="<html:rewrite page='/css/commun.css'/>">
        <link rel="icon" type="image/png" href="images/icone.ico" />
    </head>
    <body>
        <!-- Start of user code for header -->
        <jsp:include page="/javascript/generic/messages.jsp"/> 
        <!-- End of user code for header -->
        <!-- other body code here -->
        <script type="text/javascript" src="<html:rewrite page='/javascript/commun.js' />" ></script>
    </body>
  </head>
</html:html>

最新更新