Hibernate4+Spring JPA+SpringMVC+Volecity搭建web应用(二)
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应用(二)的更多相关文章
- Hibernate4+Spring JPA+SpringMVC+Volecity搭建web应用(一)
pom.xml配置 <dependencies> <!-- hibernate begin --> <dependency> <groupId>org. ...
- 联系 管理 Hibernate4+Spring JPA+SpringMVC+Volecity搭建web应用(三)
hibernate注解实体类示例 package cn.bdqn.smvc.entity; import java.io.Serializable; import javax.persistence. ...
- Spring Boot入门-快速搭建web项目
Spring Boot 概述: Spring Boot makes it easy to create stand-alone, production-grade Spring based Appli ...
- springmvc+maven搭建web项目
1.创建一个maven project 为spring1 2.进行项目的配置:默认的java 1.5 在properties中选择project facts项目进行配置,反选web之后修改java环境 ...
- springmvc+maven搭建web项目之二 通过另一种方式配置spring
1.创建maven web项目 2. 配置pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:x ...
- Spring+Druid+SpringMVC的搭建(附Demo)
最近公司事情比较少,便想利用这段空闲时间做一个自己的博客. 前端界面已经搞好,感谢杨姐的模板,自己稍微把模板没有的模块给补全了. 今天便开始自己的SSM框架搭建,数据库链接是采用数据库连接池.先上个项 ...
- SpringMVC Memcached 搭建WEB项目缓存框架
最近做的项目一直在使用memcached作为缓存来缓存各种数据,现在BOSS要在项目上加上缓存.并把任务交给我.便琢磨怎么解决这个问题. 看了很多文章,写的比较详尽靠谱的就是这篇了http://www ...
- 用dotnet core搭建web服务器(二)路由表与封装
https://gitee.com/lightsever/netcore_study/tree/master/server02_path 先上代码,首先我们把httpserver封装一下,以后用起来方 ...
- springMVC+Hibernate4+Spring整合一(配置文件部分)
本实例采用springMvc hibernate 与 spring 进行整合, 用springmvc 取代了原先ssh(struts,spring,hibernate)中的struts来扮演view层 ...
随机推荐
- Cheatsheet: 2014 03.01 ~ 03.31
.NET Should I be concerned about PDB files? async and await -Simplified-Internals Web Performance tr ...
- Cheatsheet: 2013 11.01 ~ 11.11
Other Back To Basics: Hashtables – Part2 How To Make A Game Part 1:Picking a Framework Modern Garbag ...
- How To PLAY_SOUND in Oracle Forms
Play_sound is used to play audio files in Oracle Forms, Play_Sound plays the sound object in the spe ...
- [Effective Java]第五章 泛型
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- HDU 5038 Grade(分级)
Description 题目描述 Ted is a employee of Always Cook Mushroom (ACM). His boss Matt gives him a pack of ...
- 图-用DFS求连通块- UVa 1103和用BFS求最短路-UVa816。
这道题目甚长, 代码也是甚长, 但是思路却不是太难.然而有好多代码实现的细节, 确是十分的巧妙. 对代码阅读能力, 代码理解能力, 代码实现能力, 代码实现技巧, DFS方法都大有裨益, 敬请有兴趣者 ...
- php 上传文件。$_FILES
<form name="article" method="post" enctype="multipart/form-data" ac ...
- Yii javascript 的结合 账号禁用 激活 的设置。
2014-02-16 控制器中的代码: public function actionUpdown(){ //print_r($_POST);die(); if(Buser::model()->u ...
- MYSQL 表级锁 行级锁 页面锁区别
myisam存储引擎默认是表级锁 innodb存储引擎默认是行级锁 DBD存储引擎默认是页面锁 表级锁:开销小,加锁快:不会出现死锁:锁定粒度大,发出锁冲突的概率最高,并发度最低.行级锁:开锁大, ...
- c function
/* #include<stdio.h> int is_prime(int n) { for(int i = 2; i <= n/2; i ++) if(n % 2 == 0) re ...