通行证项目应用技术 吴永照  2010.05
Agenda <ul><li>通行证项目结构 </li></ul><ul><li>Spring  多视图处理 </li></ul><ul><li>Spring 3  新功能 </li></ul><ul><li>Freemarker </li><...
通行证项目结构
Spring 多视图处理 <ul><li>Api 多视图 </li></ul><ul><ul><li>http://userapi.kaiqi.com/register/{cid} </li></ul></ul><ul><ul><li>http...
Spring 3  新功能 <ul><li>IoC </li></ul><ul><li>Rest support </li></ul><ul><li>@MVC  </li></ul><ul><li>Bean validation </li></ul>
Spring 3 : IoC <ul><li>Spring 2.5 </li></ul><ul><li>ApplicationContext context = new ClassPathXmlApplicationContext(&quot;...
Spring 3 : Rest Support <ul><li>MVC 对 Rest 支持 </li></ul><ul><ul><li>@RequestMapping </li></ul></ul><ul><ul><li>@RequestPar...
Spring 3 : @MVC <ul><li>Spring 2.5 </li></ul><ul><li><bean class=&quot;org.springframework.web.portlet.mvc.annotation.Defa...
Spring 3 : Bean Validation <ul><li>数据绑定 </li></ul><ul><li>@ModelAttribute(&quot;registerVo&quot;) RegisterVo registerVo </...
Freemarker <ul><li>多页面类型处理 </li></ul><ul><li>FreeMarkerMultipleViewResolver </li></ul><ul><li>结合 Spring 进行数据绑定 </li></ul><...
XMemcached <ul><li>Spring 3  配置  XMemcached </li></ul><ul><li>memCachedClient.set(String key, int time, Object value); </l...
开发技巧 <ul><li>SpringContextHolder </li></ul><ul><li>配置文件命名及内容分离 </li></ul><ul><li>Spring bean init() 代替 StartLinsener </li>...
Thanks! <ul><li>Q & A </li></ul>
Upcoming SlideShare
Loading in …5
×

通行证项目技术分享

2,596 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,596
On SlideShare
0
From Embeds
0
Number of Embeds
1,049
Actions
Shares
0
Downloads
30
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

通行证项目技术分享

  1. 1. 通行证项目应用技术 吴永照 2010.05
  2. 2. Agenda <ul><li>通行证项目结构 </li></ul><ul><li>Spring 多视图处理 </li></ul><ul><li>Spring 3 新功能 </li></ul><ul><li>Freemarker </li></ul><ul><li>XMemcached </li></ul><ul><li>开发技巧 </li></ul>
  3. 3. 通行证项目结构
  4. 4. Spring 多视图处理 <ul><li>Api 多视图 </li></ul><ul><ul><li>http://userapi.kaiqi.com/register/{cid} </li></ul></ul><ul><ul><li>http://userapi.kaiqi.com/register/{cid}.{format} </li></ul></ul><ul><ul><li>http://userapi.kaiqi.com/register/{cid}?format={format} </li></ul></ul><ul><ul><li>Format=json, xml </li></ul></ul><ul><li>ContentNegotiatingViewResolver </li></ul><ul><li> DynamicJacksonJsonView : json 视图 </li></ul><ul><li>MarshallingView : XML 视图 </li></ul><ul><li> SingleViewViewResolver : String 视图 </li></ul>
  5. 5. Spring 3 新功能 <ul><li>IoC </li></ul><ul><li>Rest support </li></ul><ul><li>@MVC </li></ul><ul><li>Bean validation </li></ul>
  6. 6. Spring 3 : IoC <ul><li>Spring 2.5 </li></ul><ul><li>ApplicationContext context = new ClassPathXmlApplicationContext(&quot;beans.xml&quot;); </li></ul><ul><li>UserDAO userDAO = (UserDAO) context.getBean(&quot;userDAO&quot;); </li></ul><ul><li>Spring 3 </li></ul><ul><li>ApplicationContext context = new ClassPathXmlApplicationContext(&quot;beans.xml&quot;); </li></ul><ul><li>UserDAO userDAO = context.getBean(&quot;userDAO&quot;, UserDAO.class); </li></ul><ul><li>JSR 330 </li></ul><ul><li>@Qualifier </li></ul><ul><li>@Named </li></ul><ul><li>@Qualifier 和 @Named 意义几乎相同,差异在于后者是 String base 的 @Qualifier 。而 Spring3 选择了 @Qualifier , Guice 选择了 @Named 作为 &quot; 修饰 &quot; 。包括自定 annotation 策略也相同 </li></ul><ul><li>@Inject </li></ul><ul><li>Spring3 的 @Autowired 与 JSR-330 的 @Inject 完全相同, Spring3 习惯是用 @Autowired ,而 Guice 则是有自己的 @Inject </li></ul>
  7. 7. Spring 3 : Rest Support <ul><li>MVC 对 Rest 支持 </li></ul><ul><ul><li>@RequestMapping </li></ul></ul><ul><ul><li>@RequestParam </li></ul></ul><ul><ul><li>@PathVariable </li></ul></ul><ul><ul><li>@ModelAttributes </li></ul></ul><ul><ul><li>@SessionAttributes </li></ul></ul><ul><ul><li>@CookieValue </li></ul></ul><ul><ul><li>@RequestHeader </li></ul></ul><ul><li>Rest Client : RestTemplate </li></ul><ul><li>整合 Apache HttpClient </li></ul>
  8. 8. Spring 3 : @MVC <ul><li>Spring 2.5 </li></ul><ul><li><bean class=&quot;org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping&quot;/> </li></ul><ul><li><bean class=&quot;org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter&quot;/> </li></ul><ul><li>Spring 3 </li></ul><ul><li> <mvc:annotation-driven/> </li></ul>
  9. 9. Spring 3 : Bean Validation <ul><li>数据绑定 </li></ul><ul><li>@ModelAttribute(&quot;registerVo&quot;) RegisterVo registerVo </li></ul><ul><li> <@spring.bind &quot;registerVo.username&quot; /> </li></ul><ul><li> <@spring.bind &quot;registerVo.password&quot; /> </li></ul><ul><li>JSR 303 </li></ul><ul><li>@NotNull </li></ul><ul><li>@AssertTrue, @AssertFalse </li></ul><ul><li>@Min, @Max </li></ul><ul><li>@DecimalMin, @DecimalMax </li></ul><ul><li>@Size </li></ul><ul><li>@Digits </li></ul><ul><li>@Past, @Future </li></ul><ul><li>@Pattern </li></ul><ul><li>Hibernate Validator </li></ul>
  10. 10. Freemarker <ul><li>多页面类型处理 </li></ul><ul><li>FreeMarkerMultipleViewResolver </li></ul><ul><li>结合 Spring 进行数据绑定 </li></ul><ul><li><#import &quot;/spring.ftl&quot; as spring /> </li></ul><ul><li><@spring.bind &quot;registerVo.username&quot; /> </li></ul>
  11. 11. XMemcached <ul><li>Spring 3 配置 XMemcached </li></ul><ul><li>memCachedClient.set(String key, int time, Object value); </li></ul>
  12. 12. 开发技巧 <ul><li>SpringContextHolder </li></ul><ul><li>配置文件命名及内容分离 </li></ul><ul><li>Spring bean init() 代替 StartLinsener </li></ul>
  13. 13. Thanks! <ul><li>Q & A </li></ul>

×