我无法加载css文件。尝试几乎所有方式来达到它。有人可以建议应该在哪里问题。提前谢谢。
tiles-definitions在哪里定义了tile:
var client = new MongoClient(conString);
var db = client.GetDatabase("admin");
foreach (var server in client.Cluster.Description.Servers)
{
Console.WriteLine(server.State); // Always returns disconnected.
}
template.jsp是defalut模板:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
"http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
<tiles-definitions>
<definition name="defaultTemplate" template="/WEB-INF/template/default/template.jsp">
<put-attribute name="header" value="/WEB-INF/template/default/header.jsp" />
<put-attribute name="menu" value="/WEB-INF/template/default/menu.jsp" />
<put-attribute name="body" value="/WEB-INF/template/default/body.jsp" />
<put-attribute name="footer" value="/WEB-INF/template/default/footer.jsp" />
<put-attribute name="stylesheets" value="/src/main/resources/css/layout.css" />
</definition>
</tiles-definitions>
welcomepage.jsp使用template.jsp:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Default tiles template</title>
<c:forEach var="css" items="${stylesheets}">
<link rel="stylesheet" type="text/css" href="<c:url value="${css}"/>">
</c:forEach>
</head>
<body>
<div class="page">
<tiles:insertAttribute name="header" />
<div class="content">
<tiles:insertAttribute name="menu" />
<tiles:insertAttribute name="body" />
</div>
<tiles:insertAttribute name="footer" />
</div>
</body>
</html>
dispatcher-sevrlet.xml:
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<tiles:importAttribute name="stylesheets"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Default tiles template</title>
<c:forEach var="css" items="${stylesheets}">
<link rel="stylesheet" type="text/css" href="<c:url value="${css}"/>">
</c:forEach>
</head>
<body>
<div class="page">
<tiles:insertAttribute name="header" />
<div class="content">
<tiles:insertAttribute name="menu" />
<tiles:insertAttribute name="body" />
</div>
<tiles:insertAttribute name="footer" />
</div>
</body>
</html>
答案 0 :(得分:0)
你能尝试下面这样的事吗,
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Default tiles template</title>
<link rel="stylesheet" href="<c:url value='/resources/css/layout.css'/>">
</head>
或者您可以在spring模型对象中将stylesheet
变量设置为/resources/css/layout.css
,并在jsp中将c:url中的值设置为value='${stylesheet}'
。