首页 > 开发 > JSP > 正文

Spring学习基础---多框架集成

2020-05-06 19:54:26
字体:
来源:转载
供稿:网友
ApplicationContext ctx 

1,定义资源文件获得资源文件的消息,国际化信息
<bean id="messageResource" class="org.springFramework.context.support.ResourceBoundleMessageSource">
 <property name="basenames">
  xxxx
 </property>
</bean>
将会搜索xxxx.properties,xxxx_zh.properties ,xxxx_ch.properties等。

2,
程序里使用资源文件 :ctx.getMessage(’key’,arg);
页面上使用资源文件:<spring:message code="keyxxx"/>


3,使用其他文件。
 Resource rs = ctx.getResource("classpath:config.properties");
 File file = rs.getFile();
 目录规则:
 file:c:/test。txt
 /config.properties
 classpath:config.properties
 三种方式。

4,事件传播
  不过没有找到ApplicationListener这个类。

5, WebApp获取ApplicaionContext的方法,
 首先是在webxml中进行配置,可以配置成一个listener,也可以配置成一个servlet。
 然后程序里使用WebApplicationContextUtils.getWebApplicationContext.获得饮用。

6,Spring可以和很多框架进行集成。
 Struts+Spring,Webwork+Spring。

7,Spring可以有自己的调度类,DispatherServlet。
 使用的配置文件就是beans的配置,名字可以随便取。

8,Sping配置文件(具体名字见web.xml中对ContextLoaderServlet的参数)类似于Struts的配置文件。
 定义viewer使用的是系统类:
  org.springframework.web.servlet.view.InternalResourceViewResolver
 Request mapping 使用的系统类:
  org.springframework.web.servlet.handler.SimpleUrlHandleMapping
 对Action的定义使用自定义类,但这些类都是下面类的子类:
  SimpleFormController
 Actoin的属性包括:
  1,跳转的页面,和view关联
  2,封装form类,就是一个普通的javabean。
  
9,Acition类的内容,
  实现onsubmit( 封装的form,异常对象) 返回一个ModelAndView。
  ModelAndView用字符串初始化,字符串来自Action的两个跳转view名称。
  还可以把Map传入ModelAndView构造函数,用来返回消息。

共3页上一页123下一页
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表