君子博学而日参省乎己 则知明而行无过矣

博客园 首页 新随笔 联系 订阅 管理
上一页 1 ··· 83 84 85 86 87 88 89 90 91 ··· 107 下一页

2012年5月16日 #

摘要: Customizing WebDataBinder initializationTo customize request parameter binding with PropertyEditors, etc. via Spring's WebDataBinder, you can either use @InitBinder-annotated methods within your controller or externalize your configuration by providing a custom WebBindingInitializer.Customizing 阅读全文
posted @ 2012-05-16 19:39 刺猬的温驯 阅读(363) 评论(0) 推荐(0)

摘要: Servlet中的输入参数为都是string类型,而spring mvc通过data bind机制将这些string 类型的输入参数转换为相应的command object(根据view和controller之间传输数据的具体逻辑,也可称为model attributes, domain model objects)。在这个转换过程中,spring实际是先利用java.beans.PropertyEditor中的 setAdText方法来把string格式的输入转换为bean属性,亦可通过继承java.beans.PropertyEditorSupport来实现自定义的PropertyEdit 阅读全文
posted @ 2012-05-16 19:30 刺猬的温驯 阅读(469) 评论(0) 推荐(0)

摘要: @InitBinderpublicvoidinitBinder(WebDataBinderbinder){SimpleDateFormatdateFormat=newSimpleDateFormat("yyyy-MM-dd");dateFormat.setLenient(false);binder.registerCustomEditor(Date.class,newCustomDateEditor(dateFormat,true));binder.registerCustomEditor(SystemInfo.class,newPropertyEditorSupport( 阅读全文
posted @ 2012-05-16 19:28 刺猬的温驯 阅读(526) 评论(0) 推荐(0)

摘要: [java]view plaincopymodel对象:User.java:[java]view plaincopypublicclassUser{privateintid;privateStringname;//0:男,1:女,页面上表现为radiobuttonprivateintgender;privateintage;//0:没毕业,1:已经毕业,页面上表现为checkboxprivateintgraduted;//0:没结婚,1:已经结婚,页面上表现为checkboxprivateintmarried;}form表单:<form:form id="user" 阅读全文
posted @ 2012-05-16 19:27 刺猬的温驯 阅读(3758) 评论(0) 推荐(0)

摘要: 今天碰到一个问题,页面表单上是一个id,但在表单控制器的command里是一个javabean,如果将一个String转换成javabean呢?因为已经有了一个服务于hibernate的javabean,我可不想再写一个javabean,然后再笨笨的转换。在查看SimpleFormController的API的时候,发现它有一个来自父类BaseCommandController的方法——initBinder:BaseCommandController (Spring Framework)initBinderprotected void initBinder(HttpServletRequest 阅读全文
posted @ 2012-05-16 19:26 刺猬的温驯 阅读(502) 评论(0) 推荐(0)

摘要: Cygwin is a Unix-like environment for windows.It can be obtained from:www.cygwin.comBelow are notes on how to install and setup cygwin for access to group computers.Installation Notes:Download setup.exefromwww.cygwin.com.Run application from your local harddrive.Chose next on first screen.Select &qu 阅读全文
posted @ 2012-05-16 02:57 刺猬的温驯 阅读(435) 评论(0) 推荐(0)

2012年5月15日 #

摘要: I thought that it was time to take a look at Spring’s MVC interceptor mechanism, which has been around for a good number of years and is a really useful tool.A Spring Interceptor does what it says on the tin: intercepts an incoming HTTP request before it reaches your Spring MVC controller class, or 阅读全文
posted @ 2012-05-15 06:08 刺猬的温驯 阅读(1913) 评论(0) 推荐(0)

摘要: 一、Servlet Filter与Spring interceptor的执行顺序 Filter有顺序吗?我们怎么控制filter的执行顺序。通过Tomcat的代码分析,servlet在Filter执行完成后才调用,如有多个filter怎么控制执行顺序,首先会想到在web.xml配置某个参数,例如order之类的,但查找一下一番,servlet并没有这个参数。试试filter Mapping的配置的先后顺序,果然有效,原来filter的执行顺序就考filter mapping在web.xml中的顺序。spring interceptor也是这样的执行顺序,不过interceptor多一个配置参数 阅读全文
posted @ 2012-05-15 05:15 刺猬的温驯 阅读(515) 评论(0) 推荐(0)

摘要: 在当今的MVC framework里,似乎Webwork2逐渐成为主流, Webwork2+SpringFramework的组合变得越来越流行。这似乎意味着Spring自带的MVC framework远比Webwork2差,所以大家纷纷用Webwork2来代替。确实,Spring的MVC framework不算是整个Spring的核心部件,但它的威力却超过了很多人的想象。很多人包括xiecc认为Spring的MVC framework是非常优秀的,甚至比Webwork2更优秀。下面列举一下Spring的MVC framework在设计时做出的一些重要的决定,并将之和相关的MVC framewo 阅读全文
posted @ 2012-05-15 05:14 刺猬的温驯 阅读(330) 评论(0) 推荐(0)

摘要: 假如我们在写一个基于Spring的普通应用程序,不管我们用了多么精妙的设计模式,进行了如何巧妙的设计,我们必须在某个地方执行这样的代码:ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(new String[] {"applicationContext.xml", "applicationContext-part2.xml"});appContext.getBean("…");也许这样的代码算不上丑陋,但是它无疑破坏了程序的纯洁 阅读全文
posted @ 2012-05-15 05:13 刺猬的温驯 阅读(438) 评论(0) 推荐(0)

上一页 1 ··· 83 84 85 86 87 88 89 90 91 ··· 107 下一页