是的。
boolean condition = evaluateItSomehow();
request.setAttribute("condition", condition);
request.getRequestDispatcher("/WEB-INF/page.jsp").forward(request, response);
http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/“rel=“nofollow noreferer”
<head>
<c:if test="${condition}">
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="script.js"></script>
</c:if>
...
</head>
<>Update:,因为你似乎有不止一份这方面的档案,你甚至可以通过仅仅确定所希望的档案名称(或预先确定,或甚至全名),使其更加灵活:
String suffix = evaluateItSomehow();
request.setAttribute("suffix", suffix);
request.getRequestDispatcher("/WEB-INF/page.jsp").forward(request, response);
以及
<head>
<link rel="stylesheet" type="text/css" href="style_${suffix}.css">
<script type="text/javascript" src="script_${suffix}.js"></script>
...
</head>
If you set suffix
to for example "foo"
, this will load style_foo.css
以及 script_foo.js
. I think this gives enough new insights.