SpringMVC
文章平均质量分 60
iteye_19209
这个作者很懒,什么都没留下…
展开
-
Spring MVC如何访问到静态的文件,如jpg,js,css,png,gif?
如果你的DispatcherServlet拦截 *.do这样的URL,就不存在访问不到静态资源的问题。如果你的DispatcherServlet拦截“/”,拦截了所有的请求,同时对*.js,*.jpg的访问也就被拦截了。 目的:可以正常访问静态文件,不要找不到静态文件报404。 方案一:激活Tomcat的defaultServlet来处理静态文件 Xml代码 <...原创 2016-09-23 20:42:35 · 376 阅读 · 0 评论 -
Spring ContextLoaderListener与DispatcherServlet所加载的applicationContext的区别
from: http://blog.csdn.net/madun/article/details/8988860/ spring通过在web.xml 中配置ContextLoaderListener 来加载context配置文件,在DispatcherServlet中也可以来加载spring context配置文件,那么这两个有什么区别呢。 ContextLoaderListen...原创 2017-03-14 14:45:31 · 145 阅读 · 0 评论 -
applicationContext.xml 和 springmvc-servlet.xml 配置文件加载顺序
applicationContext.xml是随ContextLoaderListener的加载而执行的, 而xxx-servlet.xml是随DispatcherServlet的加载而执行的, 在web.xml中,加载顺序是listener>filter>servlet 所以applicationContext.xml先加载!...原创 2016-12-20 15:32:32 · 461 阅读 · 1 评论 -
Spring Bean管理
from: [url]http://blog.csdn.net/a9529lty/article/details/42145545[/url] 如何取得Spring管理的bean (请用第3种方法): 1、servlet方式加载时,【web.xml】Xml代码 springMVC org.springframework.web.servlet.Dispatche...原创 2016-11-02 19:29:06 · 80 阅读 · 0 评论 -
标签<context:component-scan/><context:annotation-config/><mvc:annotation-driven/>
from: [url]http://yimengzhu.iteye.com/blog/1599441[/url] 简单讲解Spring中的 这三者的作用 [b]1 [/b] 这个标签告诉Spring到bean类中寻找一些annotation定义的类, 这些annotation基本如下: @Autowired @PostConstruct @PreDe...原创 2016-11-02 19:24:39 · 87 阅读 · 0 评论 -
DispatcherServlet 和 ContextLoaderListener 区别
总结一下: Spring的WebApplicationContext加载有2种:ContextLoaderListener和DispatcherServlet,在web.xml配置,ContextLoaderListener和DispatcherServlet有什么区别? 1 ContextLoaderListener 在我们的web容器启动的时候启动的,默认会加载/WEB...原创 2016-11-02 19:16:47 · 110 阅读 · 0 评论 -
ContextLoaderListener与DispatcherServlet所加载的applicationContext的区别
本人来自: http://blog.csdn.net/madun/article/details/8988860/ 也可以参阅本人总结:[url]http://angie.iteye.com/blog/2334955[/url] spring通过在web.xml 中配置ContextLoaderListener 来加载context配置文件,在DispatcherServlet中也可以...原创 2016-11-02 19:16:21 · 85 阅读 · 0 评论 -
spring 3.0.5的<mvc:resources> 标签的使用
from: http://ericxiong.iteye.com/blog/1009030 spring mvc 的<mvc;resources mapping="***" location="***">标签是在spring3.0.4出现的,主要是用来进行静态资源的访问。在spring3.0.4出来的时候spring还没有更新其schema所以在配置文件中有可能找不到...原创 2016-11-01 23:59:49 · 79 阅读 · 0 评论 -
Spring加载resource时classpath*:与classpath:的区别
from : http://blog.csdn.net/kkdelta/article/details/5507799 spring可以通过指定classpath*:与classpath:前缀加路径的方式从classpath加载文件,如bean的定义文件.classpath*:的出现是为了从多个jar文件中加载相同的文件.classpath:只能加载找到的第一个文件. 比如 r...原创 2016-10-19 10:14:48 · 94 阅读 · 0 评论 -
Java web工程web.xml 配置中classpath: 与classpath*:的区别
首先 classpath是指 WEB-INF文件夹下的classes目录 解释classes含义: 1.存放各种资源配置文件 eg.init.properties log4j.properties struts.xml 2.存放模板文件 eg.actionerror.ftl 3.存放class文件 对应的是项目开发时的src目录编译文件 总结:这是一个定位资源的入口 ...原创 2016-10-19 10:13:17 · 167 阅读 · 0 评论 -
spring mvc路径匹配
Ant path 匹配原则 在Spring MVC中经常要用到拦截器,在配置需要要拦截的路径时经常用到子标签,其有一个path属性,它就是用来指定需要拦截的路径的。例如: 根据以上配置,此拦截器会拦截所有的请求。 Spring MVC中的路径匹配要比标准的web.xml要灵活的多。默认的策略实现了 org.springframework.util.AntPathMat...原创 2016-10-18 22:37:56 · 263 阅读 · 0 评论 -
SpringMVC中Controller的@ResponseBody注解或HttpResponseServlet输出内容
需求分析:需要 利用 out 对象返回给财付通是否接收成功 。那么将需要如下代码: [java] view plain copy /** * 返回处理结果给财付通服务器。 * @param msg: Success or fail。 * @throws IOException */ public void sendToC...原创 2016-09-29 15:18:03 · 560 阅读 · 0 评论 -
SpringMVC 的请求参数获取的几种方法
通过@PathVariabl注解获取路径中传递参数JAVA @RequestMapping(value = "/{id}/{str}") public ModelAndView helloWorld(@PathVariable String id, @PathVariable String str) { System.out.println(id); System.out.print...原创 2016-09-28 16:57:19 · 118 阅读 · 0 评论 -
SpringMVC的各种参数绑定方式
from: http://www.cnblogs.com/HD/p/4107674.html SpringMVC的各种参数绑定方式 1. 基本数据类型(以int为例,其他类似):Controller代码: @RequestMapping("saysth.do") public void test(int count) { } 表单代码: <form ...原创 2016-09-28 16:53:11 · 78 阅读 · 0 评论 -
Spring MVC DispatcherServlet详解
Spring MVC的特点 Spring MVC框架是围绕DispatcherServlet来设计的,这个Servlet会把请求分发给各个处理器,并支持可配置的处理器映射、视图渲染、本地化、时区与主题渲染和文件上传等功能。 处理器是应用中注解了@Controller和@RequestMapping的类和方法,Spring为处理器方法提供了非常多样灵活的配置。 Spring 3.0以后提供...原创 2016-09-28 13:51:48 · 176 阅读 · 0 评论 -
SpringMVC详细示例实战教程
一、SpringMVC基础入门,创建一个HelloWorld程序 1.首先,导入SpringMVC需要的jar包。 2.添加Web.xml配置文件中关于SpringMVC的配置 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <!--configure the setting of sprin...原创 2016-09-27 11:03:49 · 74 阅读 · 0 评论 -
DispatcherServlet 和 ContextLoaderListener 的关系,到底用哪个?
from: http://www.cnblogs.com/caryfang/p/5675178.html 我们先看下这两个东东的配置方法: [img]http://dl2.iteye.com/upload/attachment/0123/6886/c84ecd27-53cd-313a-9839-8e516f02765b.png[/img] 对于contextConfigLoc...原创 2017-03-14 15:01:03 · 159 阅读 · 0 评论