SpringMVC.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:mvc="http://www.springframework.org/schema/mvc"
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:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd"> <!-- 使Spring支持自动检测组件,如注解的Controller -->
//base-package中的属性是controller所在的路径
<context:component-scan base-package="cn.bdqn.smvc.controller" />
<context:annotation-config /> <!--避免IE执行AJAX时,返回JSON出现下载文件 -->
<bean id="mappingJacksonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean> <!-- 启动SpringMVC的注解功能,完成请求和注解POJO的映射 -->
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="mappingJacksonHttpMessageConverter" /> <!-- JSON转换器 -->
</list>
</property>
</bean> <!-- jsp视图解析器 -->
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
//下面value中的是jsp所在的路径
<property name="prefix" value="WEB-INF/view/" />
<property name="suffix" value=".jsp" />
</bean> <!-- velocity视图解析器 <bean id="velocityViewResolver" class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver">
<property name="exposeRequestAttributes" value="true" /> <property name="contentType"
value="text/html;charset=UTF-8" /> <property name="prefix" value="" /> <property
name="suffix" value=".html" /> <property name="layoutUrl" value="layout.html"
/> </bean> <bean id="velocityConfigurer" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="resourceLoaderPath"> <value>WEB-INF/template/</value> </property>
<property name="velocityProperties"> <props> <prop key="input.encoding">UTF-8</prop>
<prop key="output.encoding">UTF-8</prop> <prop key="contentType">text/html;charset=UTF-8</prop>
</props> </property> </bean> -->
</beans> 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"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>smvc</display-name> <!-- spring全局监听 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> <!-- 同时加载多个spring配置文件可用 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:SpringConfig.xml
</param-value>
</context-param> <!-- spring mvc控制 -->
<servlet>
<servlet-name>mvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:SpringMVC.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc</servlet-name>
<url-pattern>*.shtml</url-pattern>
</servlet-mapping> <!-- 忽略过滤的文件 -->
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.png</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.jpg</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.js</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.css</url-pattern>
</servlet-mapping> <!-- 出错页面定义 -->
<error-page>
<error-code>500</error-code>
<location>/error.shtml</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/nofound.shtml</location>
</error-page> <welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app> 控制器示例 package cn.bdqn.smvc.controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; @Controller
public class HelloController { @RequestMapping("/hi.shtml")
public String hello(){
return "hello";
}
}

Hibernate4+Spring JPA+SpringMVC+Volecity搭建web应用(二)的更多相关文章

  1. Hibernate4+Spring JPA+SpringMVC+Volecity搭建web应用(一)

    pom.xml配置 <dependencies> <!-- hibernate begin --> <dependency> <groupId>org. ...

  2. 联系 管理 Hibernate4+Spring JPA+SpringMVC+Volecity搭建web应用(三)

    hibernate注解实体类示例 package cn.bdqn.smvc.entity; import java.io.Serializable; import javax.persistence. ...

  3. Spring Boot入门-快速搭建web项目

    Spring Boot 概述: Spring Boot makes it easy to create stand-alone, production-grade Spring based Appli ...

  4. springmvc+maven搭建web项目

    1.创建一个maven project 为spring1 2.进行项目的配置:默认的java 1.5 在properties中选择project facts项目进行配置,反选web之后修改java环境 ...

  5. springmvc+maven搭建web项目之二 通过另一种方式配置spring

    1.创建maven web项目 2. 配置pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:x ...

  6. Spring+Druid+SpringMVC的搭建(附Demo)

    最近公司事情比较少,便想利用这段空闲时间做一个自己的博客. 前端界面已经搞好,感谢杨姐的模板,自己稍微把模板没有的模块给补全了. 今天便开始自己的SSM框架搭建,数据库链接是采用数据库连接池.先上个项 ...

  7. SpringMVC Memcached 搭建WEB项目缓存框架

    最近做的项目一直在使用memcached作为缓存来缓存各种数据,现在BOSS要在项目上加上缓存.并把任务交给我.便琢磨怎么解决这个问题. 看了很多文章,写的比较详尽靠谱的就是这篇了http://www ...

  8. 用dotnet core搭建web服务器(二)路由表与封装

    https://gitee.com/lightsever/netcore_study/tree/master/server02_path 先上代码,首先我们把httpserver封装一下,以后用起来方 ...

  9. springMVC+Hibernate4+Spring整合一(配置文件部分)

    本实例采用springMvc hibernate 与 spring 进行整合, 用springmvc 取代了原先ssh(struts,spring,hibernate)中的struts来扮演view层 ...

随机推荐

  1. C#中Struct与Class的区别

    class和struct最本质的区别是class是引用类型,而struct是值类型,它们在内存中的分配情况有所区别. 什么是class? class(类)是面向对象编程的基本概念,是一种自定义数据结构 ...

  2. 异步设备IO 《windows核心编程》第10章学习

    异步IO操作与同步操作区别: 在CreateFile里的FILE_FLAG_OVERLAPPED标志 异步操作函数LPOVERLAPPED参数 接收IO请求完成通知 触发设备内核对象 缺点:同一个设备 ...

  3. Create Timer Example To Show Image Presentation in Oracle Forms

    Suppose you want to change multiple images after a specified time in home screen of your oracle form ...

  4. Javascript this指针

    Javascript是一门基于对象的动态语言,也就是说,所有东西都是对象,一个很典型的例子就是函数也被视为普通的对象.   前言 Javascript是一门基于对象的动态语言,也就是说,所有东西都是对 ...

  5. 访问者模式,visitor

    定义: 表示作用于某对象结构中的各个元素的操作. 可以在不改变各元素的类的前提下定义作用于这些元素的新操作. 前提: 适用于数据结构(Element)相对稳定的系统,这样visitor中的方法就是稳定 ...

  6. 别名alias

    alias #查看已设置的别名 alias  别名='原命令' #暂时设定别名(重启失效):alias ls='ls --color=never' unalias  别名 #删除别名 设置别名永久生效 ...

  7. 行转列:SQL SERVER PIVOT与用法解释

    在数据库操作中,有些时候我们遇到需要实现“行转列”的需求,例如一下的表为某店铺的一周收入情况表: WEEK_INCOME(WEEK VARCHAR(10),INCOME DECIMAL) 我们先插入一 ...

  8. eclipse 技巧

    1. eclipse中xml中提示需有xsd文档 如在线eclipse将自动网络获取.xsd 否则 手动本地添加(在xml catalog参数设置选项) 2.当明确实现功能时,可将已有方法抽取成接口, ...

  9. js打印出对象的方法

    var description = ""; for (var i in order) { var property = order[i]; description += i + & ...

  10. Android面试题整理【转载】

      面试宝典(5)  http://www.apkbus.com/android-115989-1-1.html 面试的几个回答技巧 http://blog.sina.com.cn/s/blog_ad ...