|
一.項(xiàng)目目錄
二.解決方法(已解決) 1. jsp文件加入 <link href="<c:url value="/css/main.css" />" rel="stylesheet" type="text/css" /> 或 <link rel="stylesheet" href="/app18b/css/main.css" type="text/css"><!-- app18b為項(xiàng)目名-> ?或 <style>
@import url("/app18b/css/main.css");
</style>
? 2.此時(shí)的web.xml <?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
xmlns="http://java./xml/ns/javaee"
xmlns:xsi="http://www./2001/XMLSchema-instance"
xsi:schemaLocation="http://java./xml/ns/javaee
http://java./xml/ns/javaee/web-app_3_0.xsd">
<!-- static resources -->
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.css</url-pattern>
<url-pattern>*.js</url-pattern>
<url-pattern>*.gif</url-pattern>
<url-pattern>*.jpg</url-pattern>
<url-pattern>*.jpeg</url-pattern>
<url-pattern>*.png</url-pattern>
<url-pattern>*.ico</url-pattern>
<url-pattern>*.zip</url-pattern>
<url-pattern>*.rar</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/springmvc-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<jsp-config>
<taglib>
<taglib-uri>http://java./jsp/jstl/fmt</taglib-uri>
<taglib-location>/WEB-INF/lib/fmt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java./jsp/jstl/fmt-rt</taglib-uri>
<taglib-location>/WEB-INF/lib/fmt-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java./jsp/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/lib/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java./jsp/jstl/core-rt</taglib-uri>
<taglib-location>/WEB-INF/lib/c-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java./jsp/jstl/sql</taglib-uri>
<taglib-location>/WEB-INF/lib/sql.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java./jsp/jstl/sql-rt</taglib-uri>
<taglib-location>/WEB-INF/lib/sql-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java./jsp/jstl/x</taglib-uri>
<taglib-location>/WEB-INF/lib/x.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java./jsp/jstl/x-rt</taglib-uri>
<taglib-location>/WEB-INF/lib/x-rt.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>
此時(shí)的springmvc-config <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www./schema/beans"
xmlns:xsi="http://www./2001/XMLSchema-instance"
xmlns:p="http://www./schema/p"
xmlns:mvc="http://www./schema/mvc"
xmlns:context="http://www./schema/context"
xsi:schemaLocation="
http://www./schema/beans
http://www./schema/beans/spring-beans.xsd
http://www./schema/mvc
http://www./schema/mvc/spring-mvc.xsd
http://www./schema/context
http://www./schema/context/spring-context.xsd">
<!-- <context:component-scan
base-package="app18b.controller" />
<mvc:default-servlet-handler/>
<mvc:annotation-driven></mvc:annotation-driven>
<mvc:annotation-driven />
靜態(tài)資源映射
<mvc:resources mapping="/css/**" location="/resources/css/"></mvc:resources>
<mvc:resources mapping="/js/**" location="/resource/js/"></mvc:resources>
<mvc:resources mapping="/img/**" location="/resource/img/"></mvc:resources>
<mvc:resources mapping="/uploads/**" location="/resource/uploads/"></mvc:resources>
Register the bean
<bean class="controller.ProductController" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean> -->
<context:component-scan base-package="controller"/>
<context:component-scan base-package="service"/>
<mvc:annotation-driven/>
<mvc:resources mapping="/css/ **" location="/css/"/>
<mvc:resources mapping="/ *.html" location="/"/>
<!-- Register the bean -->
<!-- <bean class="controller.ProductController" /> -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
? 來(lái)源:http://www./content-4-176501.html |
|
|
來(lái)自: 印度阿三17 > 《開(kāi)發(fā)》