转到正文

宁静海

发现,理解,提升

存档

2011 年 5 月 的存档

Spring是常用的开发框架,曾经以为只有2种主要的IOC容器初始化方式

1、显式的实例化ApplicationContext

2、通过web.xml配置

 

以下内容参考自Spring-Reference PDF

显式实例化:

ApplicationContext ctx = new ClassPathXmlApplicationContext("conf/appContext.xml");
//MessengerService.class用来确定2个XML文件的路径
ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] {"services.xml", "daos.xml"}, MessengerService.class);
ApplicationContext ctx = new FileSystemXmlApplicationContext("conf/appContext.xml");
ApplicationContext ctx = new FileSystemXmlApplicationContext("classpath:conf/appContext.xml");

 

web.xml配置

原理基本就是Servlet,摘自Reference PDF

To support the scoping of beans at the request, session, and global session levels
(web-scoped beans), some minor initial configuration is required before you define your beans. (This
initial setup is not required for the standard scopes, singleton and prototype.)
How you accomplish this initial setup depends on your particular Servlet environment..

对于Servlet2.4以上容器且使用了第三方的工具来控制跳转,比如Struts,则必须添加listener

<listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

 

这个添加是为了scope考量,摘自PDF

If you access scoped beans within Spring Web MVC, in effect, within a request that is processed by the
Spring DispatcherServlet, or DispatcherPortlet, then no special setup is necessary:
DispatcherServlet and DispatcherPortlet already expose all relevant state.

可以看到如果使用MVC,或者纯粹的DispatcherServlet应用等,可无须配置该listener。
If you use a Servlet 2.4+ web container, with requests processed outside of Spring’s DispatcherServlet
(for example, when using JSF or Struts), you need to add the following
javax.servlet.ServletRequestListener to the declarations in your web applications

如果request的处理过程在Dis

 

 本文保存自用开发环境的常用配置信息,用于将来能够快速重建高效开发环境。

使用技术罗列

名称 类型 版本 官方地址
eclipse IDE 3.6R2 Eclipse 3.6 Helios
 subclipse eclipse-plug-in 1.6.17 subclipse 
 gwt-plug-in eclipse-plug-in    GWT-plug-in
 oepe eclipse-plug-in  11.1.1.7.2.201103302044 OEPE 
 glassfish app server 3.1  glassfish

 

 

 

 

 

 

 

eclipse.ini  (3.6 R2)

 

-startup
plugins/org.eclipse.equinox.launcher_1.1.1.R36x_v20101122_1400.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.2.R36x_v20101222
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
-vm
D:/JTool/JDK/jdk1.6.0_25/bin/javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.6
-XX:PermSize=64m
-XX:MaxPermSize=64m
-Xmn168m
-Xms512m
-Xmx512m
-Dsun.lang.ClassLoader.allowArraySyntax=true

 

插件安装文件drop link

当前路径为eclipse安装路径

 

path=../plugin/site-1.6.17
path=../plugin/gpe-e36-latest-updatesite
path=../plugin/oepe-helios-11.1.1.7.2.201103302044

 

本地开发目录结构

我要发言 阅读全文