我有3个jsp:
template_blank.jsp模板
模板连接.jsp
模板.jsp
此jsp调用css文件-->common.css
这是template.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>
....
这是我的common.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。它用于定义不同的
height
和width
。问题是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>