關於velocity中date.format()的問題
以下是我的主要的兩個配置檔案原始碼,
整個練習的資料庫指令碼(注:mysql資料庫),以及所有原始碼在附件當中,由於jar包占的記憶體太大,所有jar包都是空,只是一個1kb空jar包
-------------------------------[b]web.xml中程式碼[/b]--------------------------------
[code]<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<welcome-file-list>
<welcome-file>index.vm</welcome-file>
</welcome-file-list>
<!-- 配置servlet -->
<servlet>
<servlet-name>dispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext-Service.xml,
/WEB-INF/applicationContext-Modules-Login.xml,
/WEB-INF/applicationContext-Modules-Client.xml,
/WEB-INF/applicationContext-Modules-Room.xml,
/WEB-INF/applicationContext-Modules-OpenRoom.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcherServlet</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>velocity</servlet-name>
<servlet-class>
org.apache.velocity.tools.view.servlet.VelocityLayoutServlet
</servlet-class>
<init-param>
<param-name>org.apache.velocity.toolbox</param-name>
<param-value>/WEB-INF/toolbox.xml</param-value>
</init-param>
<init-param>
<param-name>org.apache.velocity.properties</param-name>
<param-value>/WEB-INF/velocity.properties</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>velocity</servlet-name>
<url-pattern>*.vm</url-pattern>
</servlet-mapping>
<!-- 字元編碼配置 -->
<filter>
<filter-name>CharacterSetEncoding Filter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GB2312</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>false</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterSetEncoding Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>[/code]
---------------------[b]applicationContext-Service.xml中程式碼[/b]--------------------
[code]<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- configure some default controllers for testing and placeholder purpose -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
<property name="url"><value><![CDATA[jdbc:mysql://localhost:3306/room?useUnicode=true&characterEncoding=gb2312]]></value></property>
<property name="username"><value>root</value></property>
<property name="password"><value>root</value></property>
</bean>
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<!-- 實體對映檔案的配置 -->
<property name="mappingDirectoryLocations">
<list>
<value>classpath:/login/resources/com/login/model</value>
<value>classpath:/client/resources/com/client/model</value>
<value>classpath:/roommgr/resources/com/roommgr/model</value>
<value>classpath:/openroom/resources/com/openroom/model</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<!-- the jdbcTransactionManager -->
<bean id="jdbcTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource"><ref local="dataSource"/></property>
</bean>
<!-- configure a hibernate template -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<!-- 宣告一個velocity引擎
<bean id="velocityEngine"
class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property name="configLocation">
<value>/WEB-INF/velocity.properties</value>
</property>
<property name="resourceLoaderPath">
<value>/</value>
</property>
</bean>
-->
<bean id="velocityConfigurer" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="resourceLoaderPath">
<value>WEB-INF/velocity</value>
</property>
<property name="configLocation"><value>/WEB-INF/velocity.properties</value></property>
</bean>
<!-- 配置velocity檢視解析
<bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
<property name="suffix">
<value>.vm</value>
</property>
<property name="contentType" value="text/html;charset=gb2312" />
<property name="toolboxConfigLocation"><value>/WEB-INF/velocity-toolbox.xml</value></property>
</bean>
-->
<bean
id="viewResolver"
class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
<property name="exposeSpringMacroHelpers"><value>true</value></property>
<property name="exposeRequestAttributes"><value>true</value></property>
<property name="exposeSessionAttributes"><value>true</value></property>
<property name="requestContextAttribute"><value>rc</value></property>
<property name="cache"><value>false</value></property>
<property name="suffix"><value>.vm</value></property>
<property name="contentType"><value>text/html;charset=gb2312</value></property>
<property name="toolboxConfigLocation"><value>/WEB-INF/toolbox.xml</value></property>
</bean>
</beans>
[/code]