`
zhaoyanfangeye
  • 浏览: 122697 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

velocity配置与springMVC

阅读更多
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:spring/**/*.xml</param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
  </listener>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath*:/mvc/spring-mvc.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <!-- 
    <servlet>
    <servlet-name>velocity</servlet-name>
    <servlet-class>
      org.apache.velocity.tools.view.servlet.VelocityViewServlet
    </servlet-class>
    <load-on-startup>10</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>velocity</servlet-name>
    <url-pattern>*.html</url-pattern>
  </servlet-mapping>
   -->
  <servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>/app/*</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

spring-mvc.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" 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.1.xsd
	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd 
	 http://www.springframework.org/schema/aop 
  http://www.springframework.org/schema/aop/spring-aop-3.1.xsd 
  http://www.springframework.org/schema/mvc 
			http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
	<mvc:annotation-driven />
		
	<context:component-scan base-package="com.nahai.view.controller" />
	
	<context:annotation-config />
	<!-- <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> 
		<property name="basenames"> <list> <value>/WEB-INF/messages/messages</value> 
		<value>/WEB-INF/messages/expMessages</value> <value>/WEB-INF/messages/chartMessages</value> 
		</list> </property> <property name="cacheSeconds" value="-1" /> </bean> \ -->
	
	<!--  解析器-->
	<!-- <bean
		class="org.springframework.web.servlet.view.InternalResourceViewResolver"
		p:prefix="/view/" p:suffix=".html" /> --> 
	
	    <!-- velocity解析器 -->
     <bean id="viewResolver"
                        class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"> 
                        <property name="contentType" 
                            value="text/html;charset=UTF-8" />
                         <property name="suffix" value=".html" /> 
    </bean> 
		
     <!-- velocity引擎 -->
    <bean id="velocityConfigurer" 
        class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> 
        <property name="resourceLoaderPath"> 
            <value>/view/</value> 
        </property> 
        <!--<property name="configLocation" value="/WEB-INF/velocity.properties" />  -->
        <property name="velocityProperties">   
         <props>   
             <prop  key="input.encoding">UTF-8</prop>   
             <prop  key="output.encoding">UTF-8</prop>     
          </props>   
      </property>   
    </bean> 
</beans>

maven
	<dependency>
       <groupId>velocity</groupId>
        <artifactId>velocity</artifactId>
        <version>1.7</version>
        <systemPath>D:/workspace/showView/src/main/webapp/WEB-INF/lib/velocity-1.7.jar</systemPath>
        <scope>system</scope>
	</dependency>
	<dependency>
       <groupId>velocity</groupId>
        <artifactId>velocity-tools-view-2.0.jar</artifactId>
        <version>2.0</version>
        <systemPath>D:/workspace/showView/src/main/webapp/WEB-INF/lib/velocity-tools-2.0.jar</systemPath>
        <scope>system</scope>
	</dependency>
	<dependency>
       <groupId>commons</groupId>
        <artifactId>collections.jar</artifactId>
        <version>1.0</version>
        <systemPath>D:/workspace/showView/src/main/webapp/WEB-INF/lib/commons-collections.jar</systemPath>
        <scope>system</scope>
	</dependency>
     <dependency>
       <groupId>commons</groupId>
        <artifactId>lang.jar</artifactId>
        <version>1.0</version>
        <systemPath>D:/workspace/showView/src/main/webapp/WEB-INF/lib/commons-lang.jar</systemPath>
        <scope>system</scope>
	</dependency>
	  <dependency>
       <groupId>commons</groupId>
        <artifactId>commons-digester-1.8.jar</artifactId>
        <version>1.8</version>
        <systemPath>D:/workspace/showView/src/main/webapp/WEB-INF/lib/commons-digester-1.8.jar</systemPath>
        <scope>system</scope>
	</dependency>
		  <dependency>
       <groupId>commons</groupId>
        <artifactId>commons-beanutils-1.8.3.jar</artifactId>
        <version>1.8</version>
        <systemPath>D:/workspace/showView/src/main/webapp/WEB-INF/lib/commons-beanutils-1.8.3.jar</systemPath>
        <scope>system</scope>
	</dependency>
分享到:
评论

相关推荐

    SpringMVC3+velocity最简单配置例子

    SpringMVC3+velocity最简单配置例子,入门级的demo

    springmvc+velocity

    J2EE开发中velocity获取项目地址,使用框架springmvc+velocity视图器,velocity配置toolboxConfigLocation使.vm文件获取项目资源地址和设置静态资源地址。 此处demo实现效果为:test.vm模板通过调用${ctx.rootPath}...

    springMVC+maven+velocity+数据源配置

    springMVC架构,maven , velocity , 数据源配置在项目中(springMVC的配置文件中)。

    Spring MVC+Maven+Velocity配置实例

    Spring MVC+Maven+Velocity配置实例

    springmvc+mybatis+velocity整合实例

    采用最新的springmvc3.2、mybatis3.2、velocity1.7整合,完整的配置文件和测试例子,注解完成,轻量级的视图搭配

    SpringMVC+ibatis+velocity整合例子

    SpringMVC+ibatis+velocity整合例子,虽然比较简单。可以为没有配置好的同学作为参考。

    Springmvc4.0.6+mybatis3.2.7+velocity1.7+log4j2

    框架采用最流行技术springmvc4.0.6,和最流行持久层框架mybatis3.2.7,还有Velocity - 模板引擎,还有最新日志输出log4j2的配置并且分级别输出到不同文件, 感兴趣赶紧下载吧

    springmvc+velocity+hession+ibatis

    基于springmvc框架,基本jar包都在,下载后配置改改,有些包可能不存在,但是无妨碍,改改即可运行,值得研究

    velocity jsp多视图解析器整合

    整合velocity和jsp 通过不同视图解析器,返回不同视图

    webapp_sample:一个基于Velocity+SpringMVC+Spring+MyBatis架构的网站示例

    这是一个基于Velocity+SpringMVC+Spring+MyBatis架构的网站示例。 1.生成工程的步骤(前提jdk,eclipse,gradle都已安装配置完毕): 1)创建webapp目录,然后编写build.gradle 2)运行gradle createWebProject命令,...

    跟开涛学SpringMVC

    通过策略接口,Spring 框架是高度可配置的,而且包含多种视图技术,例如 JavaServer Pages(JSP)技术、Velocity、Tiles、iText和POI。Spring MVC 框架并不知道使用的视图,所以不会强迫您只使用 JSP 技术。Spring ...

    SpringMVC实例

    4、SpringMVC是真正的View层实现无关的,它不会强制开发员使用JSP,我们可以使用其他View技术,比如Velocity,Xskt等。 5、国际化支持,Spring的ApplicationContext提供了对国际化的支持,在这里可以很方便的使用。 6...

    springMVC 3.2.0版本

    通过策略接口,Spring 框架是高度可配置的,而且包含多种视图技术,例如 JavaServer Pages(JSP)技术、Velocity、Tiles、iText和POI。Spring MVC 框架并不知道使用的视图,所以不会强迫您只使用 JSP 技术。Spring ...

    SpringMVC_HelloWorld:SpringMVC的一个hello world的demo,开启学习SpringMVC的大门

    SpringMVC还包含多种视图技术,例如 JSP,Velocity,Tiles,iText和POI等。SpringMVC分离了控制器。 SpringMVC具有如下特点: SpringMVC具有强大的灵活性,非侵入性和可配置性 SpringMVC提供了一个前端控制器...

    spring+mybatis+velocity项目demo

    分享一个spring+mybatis+velocity项目demo,该项目是之前给一个学第学习用的,主要基于springMVC、mybatis、velocity搭建的,使用maven构建,其中zai service层编写了两个简单组件,一个是email发送,一个是认证授权...

    基于springMVC的论坛

    运行resin目录下的httpd.exe文件即可(请确保resin解压在D盘根目录下面,由于配置的时候是写死的引用D:\resin-pro-3.1.12\lib\aspectjweaver-1.7.0.jar)共有3个解压缩文件,由于csdn限制只能分解成多个文件上传,请...

    SpringMVC入门实例及详细讲解

    通过策略接口,Spring 框架是高度可配置的,而且包含多种视图技术,例如 JavaServer Pages(JSP)技术、Velocity、Tiles、iText 和 POI。Spring MVC 框架并不知道使用的视图,所以不会强迫您只使用 JSP 技术。Spring...

    SpringMVC教程

    通过策略接口,Spring 框架是高度可配置的,而且包含多种视图技术,例如 JavaServer Pages(JSP)技术、Velocity、Tiles、iText 和POI。Spring MVC 框架并不知道使用的视图,所以不会强迫您只使用 JSP 技术。Spring ...

    springMVC入门教程

    高度可配置的,而且包含多种视图技术,例如JavaServer Pages(JSP)技术、Velocity、Tiles、iText 和 POI。Spring MVC 框架并不知道使用的视图,所以不会强迫您只使用JSP 技术。Spring MVC 分离了控 制器、模型对象...

Global site tag (gtag.js) - Google Analytics