Css没有工作主题解析器spring mvc

时间:2016-01-20 10:33:56

标签: java css spring-mvc

我是初学mvc并开发应用程序的新手。我想改变主页的主题。但是,在遵循必要的步骤后,我无法看到任何变化。下面是代码以及我的应用程序的目录结构:

弹簧调度-servlet.xml中

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:context="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-3.0.xsd
   http://www.springframework.org/schema/context 
   http://www.springframework.org/schema/context/spring-context-3.0.xsd
   http://www.springframework.org/schema/mvc
   http://www.springframework.org/schema/mvc/spring-mvc.xsd">

   <context:component-scan base-package="com.jobsearchs"/>
   <mvc:annotation-driven/>
   <mvc:interceptors>
    <mvc:interceptor>
        <mvc:mapping path="/Login.html"/>
        <bean class="com.jobsearchs.UriInterceptor"/>
    </mvc:interceptor>
    <mvc:interceptor>
        <mvc:mapping path="/Logout.html"/>
        <bean class="com.jobsearchs.EndTimeInterceptor"/>
    </mvc:interceptor>

   </mvc:interceptors>

   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="prefix" value="/WEB-INF/" />
      <property name="suffix" value=".jsp" />
   </bean>
   <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
            <property name="url" value="jdbc:mysql://localhost:3306/jobsearch"/>
            <property name="username" value="root"/>
            <property name="password" value="1234"/>
        </bean>
   <bean id="uuserDao" class="com.jobsearchs.userDao">
            <property name="dataSource" ref="dataSource"/>
        </bean>
   <bean id="themeSource" class="org.springframework.ui.context.support.ResourceBundleThemeSource">
    <property name="basenamePrefix" value="theme-"/>
   </bean>
<bean id="themeChangeInterceptor"
    class="org.springframework.web.servlet.theme.ThemeChangeInterceptor">
    <property name="paramName" value="theme" />
</bean>
<bean id="themeResolver"
    class="org.springframework.web.servlet.theme.CookieThemeResolver">
    <property name="defaultThemeName" value="default" />
</bean>
<mvc:resources mapping="/themes/**" location="/resources/themes/"></mvc:resources>

 <mvc:interceptors>
    <ref bean="themeChangeInterceptor"/>
</mvc:interceptors> 
   </beans>

AdminUserPage.jsp

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

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 <link rel="stylesheet" href="<spring:theme code='styleSheet'/>" type="text/css"/>

 <!--  <link rel="stylesheet" href="/red.css" type="text/css"/>-->
<title>Job Search</title>
</head>
<body>
<form:errors path="u1.*"/>
<span style="float: left">
    <a href="?theme=default">default</a> 
    | 
    <a href="?theme=grey">grey</a>
    | 
    <a href="?theme=red">red</a>
</span><br><br>
<form action="/JobSearch/Login.html" method="POST">
<h1>Login</h1>
<table>
    <tr>
        <td>Name:</td><td><input type="text" name="uname"/></td>
        <td>Password:</td><td><input type="password" name="password"/></td>
    </tr>
</table>
<input type="submit" value="login"/>
</form>
<br><br>
<form action="/JobSearch/Register.html" method="POST">
<h1>Register</h1>
<table>
    <tr>
        <td>Name:</td><td><input type="text" name="uname"/></td>
        <td>Password:</td><td><input type="password" name="password"/></td>
        <td>Confirm Password:</td><td><input type="password" name="cpwd"/></td>
        <td>Email Id:</td><td><input type="text" name="emailid"/></td>
        <td>Contact Number:</td><td><input type="text" name="contactno"/></td>
        <td>Select Your Position: </td><td><select name="position"><option value="Recruiter" selected>Recruiter</option>
        <option value="Joinee">Joinee</option></select></td>
    </tr>
</table>
<input type="submit" value="Register"/>
</form>
</body>
</html>

Besides this,
I have made three property files with the following specifications:
1) theme-default.properties:-styleSheet=/themes/default.css
2) theme-grey.properties:-styleSheet=/themes/grey.css
3) theme-red.properties:-styleSheet=/themes/red.css

Along with this I am posting my directory structure:

enter image description here

请帮助。

0 个答案:

没有答案