在具有 Spring MVC 的 jsp 页面中包含样式表
我在从jsp页面链接到样式表时遇到问题。我相信这与我的目录结构有关,即:
WEB-INF
  |-- css
  |    |-- main.css
  |
  |-- jsp
       |-- login.jsp
我尝试了各种形式的标准html链接标签,例如:
<link href="css/main.css" rel="stylesheet" type="text/css" media="screen" />
<link href="main.css" rel="stylesheet" type="text/css" media="screen" />
<link href="WEB-INF/css/main.css" rel="stylesheet" type="text/css" media="screen" />
我还尝试将css文件包含在jsp文件夹中并直接链接到它。没有任何效果。当我在部署后查看源代码并尝试直接访问CSS文件时,它不存在,但这对我来说并不奇怪,因为它位于WEB-INF目录中。
我还验证了它是否与应用程序的其余部分一起部署。jsp 源代码是:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
<link href="css/main.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
<div id="header">
<div id="logout"> </div>
<h1>Login</h1>
</div>
<div id="content" class="content">
  <form action="" method="post" name="login-form">
    <fieldset>
      <legend>Login</legend>
      <table border="0" align="center">
        <tr>
          <td><label>User Name:</label></td>
        <td><input type="text" name="userName" /><br><br></td>
        </tr>
        <tr>
            <td><label>Password:</label></td>
        <td><input type="text" name="password" /><br><br></td>
         </tr>
        </table>
      </fieldset>
      <div class="buttons">
        <input type="submit" name="submit" value="Login" />   
        <input type="button" name="cancel" value="Cancel" />
      </div>
    </form>
  </div>
</div>
</body>
</html>
谢谢!
 
					 
				 
				    		 
				    		 
				    		 
				    		