浏览 9629 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-07-18
以下是我的主要的两个配置文件源代码, 整个练习的数据库脚本(注:mysql数据库),以及所有源代码在附件当中,由于jar包占的内存太大,所有jar包都是空,只是一个1kb空jar包 -------------------------------web.xml中代码-------------------------------- <?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> ---------------------applicationContext-Service.xml中代码-------------------- <?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> 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2007-07-18
看看你的日志,依照出错提示DEBUG
|
|
返回顶楼 | |
发表时间:2007-07-18
|
|
返回顶楼 | |
发表时间:2007-07-19
都没有看到你的VELECITY的配置文件, 没有配置怎么用哦
|
|
返回顶楼 | |
发表时间:2007-07-20
---------------------toolbox.xml中配置代码如下--------------------
<?xml version="1.0"?> <toolbox> <xhtml>true</xhtml> <tool> <key>link</key> <scope>request</scope> <class>org.apache.velocity.tools.struts.StrutsLinkTool</class> </tool> <!-- The MessageTool is used to render internationalized message strings. Source of the strings are the message resource bundles of the Struts framework. The following methods operate on these message resources. Method Overview get() Looks up and returns the localized message for the specified key. exists() Checks if a message string for a specified message key exists for the user's locale. --> <tool> <key>text</key> <scope>request</scope> <class>org.apache.velocity.tools.struts.MessageTool</class> </tool> <tool> <key>errors</key> <scope>request</scope> <class>org.apache.velocity.tools.struts.ErrorsTool</class> </tool> <tool> <key>form</key> <scope>request</scope> <class>org.apache.velocity.tools.struts.FormTool</class> </tool> <!-- http://velocity.apache.org/tools/releases/1.3/generic/: Example of formatting the "current" date: $date -> Oct 19, 2003 9:54:50 PM $date.long -> October 19, 2003 9:54:50 PM PDT $date.medium_time -> 9:54:50 PM $date.full_date -> Sunday, October 19, 2003 $date.get('default','short') -> Oct 19, 2003 9:54 PM $date.get('yyyy-M-d H:m:s') -> 2003-10-19 21:54:50 Example of formatting an arbitrary date: $myDate -> Tue Oct 07 03:14:50 PDT 2003 $date.format('medium',$myDate) -> Oct 7, 2003 3:14:50 AM --> <tool> <key>date</key> <scope>application</scope> <class>org.apache.velocity.tools.generic.DateTool</class> <parameter name="format" value="yyyy-MM-dd" /> </tool> <!-- Tool for working with Lists and arrays in Velocity templates. It provides a method to get and set specified elements. Also provides methods to perform the following actions to Lists and arrays: Check if it is empty. Check if it contains a certain element. Example uses: $primes -> new int[] {2, 3, 5, 7} $list.size($primes) -> 4 $list.get($primes, 2) -> 5 $list.set($primes, 2, 1) -> (primes[2] becomes 1) $list.get($primes, 2) -> 1 $list.isEmpty($primes) -> false $list.contains($primes, 7) -> true --> <tool> <key>list</key> <scope>application</scope> <class>org.apache.velocity.tools.generic.ListTool</class> </tool> <!-- Single Property Sort #foreach($obj in $sorter.sort($objects, "name")) $obj.name Ordinal= $obj.ordinal #end End Multiple Property Sort #foreach($obj in $sorter.sort($objects, ["name", "ordinal"])) $obj.name, $obj.ordinal #end End By default the sort tool sorts ascending, you can override this by adding a sort type suffix to any property name. The supported suffixes are: For ascending :asc For descending :desc Example #foreach($obj in $sorter.sort($objects, ["name:asc", "ordinal:desc"])) $obj.name, $obj.ordinal #end This will sort first by Name in ascending order and then by Ordinal in descending order, of course you could have left the :asc off of the 'Name' property as ascending is always the default. --> <tool> <key>sorter</key> <scope>application</scope> <class>org.apache.velocity.tools.generic.SortTool</class> </tool> </toolbox> |
|
返回顶楼 | |
发表时间:2007-07-20
-------------------------velocity.properties配置代码-----------------------
input.encoding=GB2312 output.encoding=GB2312 #default.contentType=text/xml default.contentType=text/html; charset=GB2312 #resource.loader=file #file.resource.loader.class=org.apache.velocity.runtime.resource.loader.FileResourceLoader #file.resource.loader.path = ./vm/ #file.resource.loader.cache=true #file.resource.loader.modificationCheckInterval=2 velocimacro.library=./vm/VM_global_library.vm runtime.log.logsystem.class= # Filepath for error template, # relative to web application root directory tools.view.servlet.error.template=Error.htn # Directory for layout templates, # relative to web application root directory tools.view.servlet.layout.directory=vm/layout/ # Filepath of the default layout template # relative to the layout directory # NOT relative to the root directory of the webapp! tools.view.servlet.layout.default.template=commons-layout.vm |
|
返回顶楼 | |