Contextpage变量不起作用??? JSP文件中不支持CSS

时间:2019-07-27 09:19:08

标签: spring maven jsp

我是Spring MVC的新手。我的jsp文件不支持css文件。

项目目录: enter image description here

我的login.jsp文件:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="description" content="Creative - Bootstrap 3 Responsive Admin Template">
  <meta name="author" content="GeeksLabs">
  <meta name="keyword" content="Creative, Dashboard, Admin, Template, Theme, Bootstrap, Responsive, Retina, Minimal">
  <link rel="shortcut icon" href="img/favicon.png">

  <title>Login Page 2 | Creative - Bootstrap 3 Responsive Admin Template</title>

  <!-- Bootstrap CSS -->


  <link href="${pageContext.request.contextPath}/resources/css/main.css" rel="stylesheet" >
  <link href="${pageContext.request.contextPath}/resources/css/bootstrap-theme.css" rel="stylesheet" >
  <link href="${pageContext.request.contextPath}/resources/css/elegant-icons-style.css" rel="stylesheet" >
  <link href="${pageContext.request.contextPath}/resources/css/font-awesome.css" rel="stylesheet" >
  <link href="${pageContext.request.contextPath}/resources/css/style.css" rel="stylesheet" >
  <link href="${pageContext.request.contextPath}/resources/css/style-responsive.css" rel="stylesheet" >

</head>

<body class="login-img3-body">

  <div class="container">

    <form class="login-form" action="index.html">
      <div class="login-wrap">
        <p class="login-img"><i class="icon_lock_alt"></i></p>
        <div class="input-group">
          <span class="input-group-addon"><i class="icon_profile"></i></span>
          <input type="text" class="form-control" placeholder="Username" autofocus>
        </div>
        <div class="input-group">
          <span class="input-group-addon"><i class="icon_key_alt"></i></span>
          <input type="password" class="form-control" placeholder="Password">
        </div>
        <label class="checkbox">
                <input type="checkbox" value="remember-me"> Remember me
                <span class="pull-right"> <a href="#"> Forgot Password?</a></span>
            </label>
        <button class="btn btn-primary btn-lg btn-block" type="submit">Login</button>
        <button class="btn btn-info btn-lg btn-block" type="submit">Signup</button>
      </div>
    </form>
    <div class="text-right">
      <div class="credits">

          Designed by <a href="https://bootstrapmade.com/">BootstrapMade</a>
        </div>
    </div>
  </div>


</body>

</html>

我的servlet.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns = "http://www.springframework.org/schema/beans"
    xmlns:ctx = "http://www.springframework.org/schema/context"
    xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
    xmlns:mvc = "http://www.springframework.org/schema/mvc"
    xsi:schemaLocation = "http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-2.5.xsd">

    <ctx:annotation-config></ctx:annotation-config>
    <ctx:component-scan base-package = "com.old.project013"></ctx:component-scan>

    <bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix">
        <value>/</value>
    </property>
    <property name="suffix">
        <value>.jsp</value>
    </property>
    </bean>

    <mvc:resources mapping="/resources/**" location="/resources/"  
    cache-period="31556926"/>

    <mvc:annotation-driven />
</beans>

我正在尝试显示带有自定义主题的UI。我已经走了。我想从“ login.jsp”文件中的“ resources / css”文件夹中获取CSS和JS文件。 在常规HTML中,我们仅使用'/folder/folder/filename.extension'这种方法。但是在我的项目中,我无法使用它。在Spring MVC中还有其他使用CSS和JS文件的方法吗? 正如我之前告诉您的那样,我不熟悉Spring MVC,所以我不知道该怎么做。 请给我一些资源或博客或其他参考,对我有帮助,

TIA

0 个答案:

没有答案