1. ที่ index.css
*{
color : red
}
2. ที่ dispatcher-servlet.xml<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:p="http://www.springframework.org/schema/p"
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-3.1.xsd">
<context:component-scan base-package="com.blogspot.na5cent" />
<mvc:annotation-driven/>
<mvc:resources mapping="/static-resc/**" location="/resources/"/>
<mvc:default-servlet-handler/>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
เราจะต้องกำหนด <mvc:resources mapping="/static-resc/**" location="/resources/"/> ว่าจะให้อ้างอิงไปที่ไหน2. การเรียกใช้งาน ที่ index.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>${pageTitle}</title>
<link rel="stylesheet" href="<c:url value="/static-resc/index.css"/>"/>
</head>
<body>
<h1>Hello World! System</h1>
</body>
</html>



ไม่มีความคิดเห็น:
แสดงความคิดเห็น