- 浏览: 241924 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
sweed0:
为何每一段代码都重复一次呢?
spring注解实例二 -
Gary_Huangpf:
- - 插件报错啊
Ext前台分页 -
ddvk2007:
版主 我想請問你所說的mapreduce是hadoop的還是g ...
MapReduce中的Shuffle和Sort分析 -
人可木:
好问章,楼主写的相当详细。。。多谢。。。
findbugs插件的安装与应用 -
hautbbs:
按照博主的方法启动调试出现jvm terminated.Ex ...
10分钟学会使用MyEclipse断点调试js
1、web.xml配置文件:
<?xml version="1.0" encoding="gb2312"?>
<web-app version="2.4"
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">
<!--
- Location of the Log4J config file, for initialization and refresh checks.
- Applied by Log4jConfigListener.
-->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.xml</param-value>
</context-param>
<!-- 为了能够加载日志文件,故需要配置一个日志监听器 -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<!-- 设置Ioc配置文件的名称为
/WEB-INF/applicationContext.xml,
/WEB-INF/classes/jdbc.xml,
/WEB-INF/spring-config.xml,
/WEB-INF/config/spring/*.xml
如果不配置,则它会读取默认的文件名/WEB-INF/action-servlet.xml-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext.xml,
/WEB-INF/classes/jdbc.xml,
/WEB-INF/spring-config.xml,
/WEB-INF/config/spring/*.xml
</param-value>
</context-param>
<!-- 为了能够加载Spring的Bean配置,故配置一个监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- filters -->
<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>
<!-- spring Dispatcher -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!-- 异常处理 -->
<error-page>
<error-code>404</error-code>
<location>/commons/404.jsp</location>
</error-page>
<!--
<error-page>
<error-code>500</error-code>
<location>/commons/error.jsp</location>
</error-page>-->
<!-- 没有数据的异常处理
<error-page>
<exception-type>org.springframework.dao.EmptyResultDataAccessException</exception-type>
<location>/commons/nodata.jsp</location>
</error-page>
-->
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
2、视图解析器的配置
<!-- Defination of view Resolver -->
<!-- 视图解析器的配置InternalResourceViewResolver
它支持InternalResourceView(对servlet和jsp的包装),以及其子类JstlView和TilesView
通过setViewClass方法,可以指定用于该解析器生成视图使用的视图类。如下为:JstlView视图类。
-->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass">
<value>org.springframework.web.servlet.view.JstlView</value>
</property>
</bean>
3、处理器的配置<!-- Controller配置 -->
<!-- 登录演示
为了选择不同的方法入口,我们需要定义方法解析器。ParameterMethodNameResolver为最常用的。
ParameterMethodNameResolver 为默认的解析器实现类,并指定提取方法名的参数为action,
默认的方法名为showLoginForm。
-->
<bean id="loginAction" class="com.ztes.sl.rmtes.action.demo.LoginAction">
<property name="methodNameResolver">
<bean class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
<property name="paramName"><value>action</value></property>
<property name="defaultMethodName"><value>showLoginForm</value></property>
</bean>
</property>
<property name="formView" value="/pages/demo/login.jsp"/>
<property name="successView" value="/pages/demo/loginSuccess.jsp"/>
</bean>
4、处理器映射的配置
<!-- 1. SimpleUrlHandlerMapping是最常用的HandlerMapping处理器映射,
它在应用上下文中可以进行配置,并且有Ant风格的路径匹配功能。
2.其中定义了一个拦截器(spring的处理器映射支持拦截器),它必须实现HandlerInterceptor
接口,这个接口定义了3个方法,一个在处理器执行前被调用,一个在处理器执行后被调用,另一个在
整个请求处理完成后被调用。
3.下面的例子提供了一个拦截器RequestHandlerInterceptor,它拦截mappings中的所有请求。
-->
<bean id="urlMappingAlarmRight" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="interceptors">
<list>
<ref bean="RequestHandlerInterceptor" />
</list>
</property>
<property name="mappings">
<props>
<!-- 列表 -->
<prop key="/alarm/forecast.do">forecastAction</prop>
</props>
</property>
</bean>
发表评论
-
spring AOP
2012-06-13 11:14 881先简单的说说spring aop使用的好处:利用AOP横向添加 ... -
spring IOC的使用
2012-06-13 10:58 930Ioc和他的作用,简单的来讲,就是由容器控制程序之间的关 ... -
spring IOC介绍
2012-06-13 10:55 1299首先想说说IoC(Inversion of ... -
spring概述
2012-06-13 10:52 776随着越来越多的项目 ... -
spring学习总结
2010-02-04 08:49 948先说说简单地使用Struts2做Web时的经历: 1.经常需要 ... -
spring注解实例二
2010-01-26 11:22 2338昨天对Spring注解有了一个整体认识,至少完成了一个简单的w ... -
spring注解实例一
2010-01-26 11:15 2924先来构建一个极为简单的web应用,从controller到da ... -
spring注解配置文件解析
2010-01-26 11:01 35481、applicationContext.xml ... -
使用 Spring 2.5 基于注解驱动的 Spring MVC(二)
2010-01-22 11:13 3400我们在 ② 处添加了一个 ModelMap 属性,其属性名为 ... -
使用 Spring 2.5 基于注解驱动的 Spring MVC(一)
2010-01-22 11:05 1330基于注解的配置有越来越流行的趋势,Spring 2.5 顺应这 ... -
spring注解详解
2010-01-22 09:57 13241.准备工作(1)导入common-annotations.j ... -
spring注解
2010-01-13 09:56 979Spring JSR-250注解 注释配 ... -
Spring MVC 配置【转】
2010-01-03 14:51 1033一,配置分发器 Dispatche ... -
spring mvc 学习笔记
2010-01-03 14:41 1135一、与struts的不同 1.Spr ... -
Spring Mvc快速入门
2010-01-03 14:20 1727Spring MVC是结构最清晰的MVC ... -
Spring 可代码简化操作类
2009-12-28 09:31 1036SimpleJdbcTemplate类是Jd ... -
Spring 命名参数操作类NamedParameterJdbcTemplate
2009-12-28 09:28 1764在传统的SQL语句中,参数都是用'?'占 ... -
Spring JdbcTemplate操作类
2009-12-24 10:42 27471.JdbcTemplate ...
相关推荐
hibernate spring 配置的详细说明
阐述spring的数据源配置
Spring配置Freemarker视图解析器,配置多个视图解析器
springsecurity使用配置详解,压缩包里包含主要的代码和详细的word文件说明。
Spring源码分析:配置文件读取流程 - ImportNew
全面解析spring事务配置的五种方式,好不容易找到的
6 Spring Boot 配置分析(一)38:26 7 Spring Boot 配置分析(二)35:47 8 Spring Boot 自动配置32:44 9 Spring Boot @Enable*注解的工作原理47:07 10 Spring Boot @EnableAutoConfiguration深入分析30:55 11 ...
主要是讲spring自定义xml配置的扩展相关的内容,东西不算新的,都是比较基础的,想看就看一下 我也是为了搞点积分才上传的
而一般的启动过程,Spring会使用一个默认的实现,XmlWebApplicationContext – 这个上下文实现作为在web容器中的根上下文容器被建立起来,具体的建立过程在下面我们会详细分析。 Java代码 public class ...
<description>Spring公共配置文件 <!-- mes 的數據庫 --> <property name="driverClass" value="oracle.jdbc.driver.OracleDriver"/> ...
在spring环境中通过component-scan配置处理自定义java注解
模拟spring的xml配置文件注入对象,里面用saxbuilder来解析xml文件。
Spring Cloud Eureka 常用配置解析.doc
Spring Boot 拦截器 各项日志 通过kibana具体查询分析 Advanced Settings [7.2.0] 综合分析 定时任务执行日志 数据同步日志 用户访问操作日志 异常日志 内存日志 Spring逻辑参数执行日志 SQL...
最近使用了springAOP编程,文档里面包含了springAOP的代码示例及详细注释说明,使用的是注解配置模式
主要介绍了Spring常用配置及解析类说明,涉及Spring常用配置项的方法以及它的解析类等相关内容,具有一定参考价值,需要的朋友可以了解下。
我们在使用SpringSecurity作为后台权限框架的时候,框架给我们提供了配置登录请求的接口,供我们配置登录链接,当我们配置了登录链接地址后,前端访问登陆请求的时候显示无权限。 异常分析 由于SpringSecurity的...
主要介绍了Spring读取配置文件属性实现方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
2.1.2 Spring Boot项目构建过程解析 24 2.2 使用起步依赖 27 2.2.1 指定基于功能的依赖 28 2.2.2 覆盖起步依赖引入的传递依赖 29 2.3 使用自动配置 30 2.3.1 专注于应用程序功能 31 2.3.2 运行应用程序...
Spring配置Freemarker视图解析器,前台页面全部使用freemarker渲染