Spring中关于view层的一些配置和使用方法

Spring中关于view层的一些配置和使用方法
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass">
<value>org.springframework.web.servlet.view.JstlView</value>
</property>
<property name="prefix"><value>/WEB-INF/view/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean id="RegisterValidator" class="net.example.validator.RegisterValidator"/>
<bean id="RegisterAction"class="net.example.action.RegisterAction">
<property name="commandClass">
<value>net.example.bean.CmdInfoBean</value>
</property>
<property name="validator"> <ref local="RegisterValidator"/></property>
<property name="formView"> <value>register</value></property>
<property name="successView" value="RegisterSuccess" />
</bean>
 
<!--Request Mapping 放在隐含的/WEB-INF/action-servlet.xml或其他显式包含的配置xml文件-->
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/register.do">RegisterAction</prop>
</props>
</property>
</bean>
 
数据验证类
在Spring中,所有的数据验证类都必须实现接口org.springframework.validation.Validator
Validator接口定义了两个方法:
boolean supports(Class clazz);
用于检查当前输入的数据类型是否符合本类的检验范围。Spring调用Validator实现类时,首先会通过这个方法检查数据类型是否与此Validator相匹配。
void validate(Object obj, Errors errors);
数据校验方法。Validator实现类通过实现这个方法,完成具体的数据校验逻辑。
 
 
 
*************************************************
Spring IDE的使用
 
下载了spring ide, 其具体的使用方法。
Usage
Fresh Installation
Add Spring Beans project nature
select open project nodes in Eclipse resource navigator, or JDT package explorer
 在Eclipse的resource navigator窗口中打开项目,(或者在 JDT package explorer窗口)
activate context menu item "Add Spring Beans Project Nature" on selected projects -> these projects are now decorated with a small 'S' in the upper right corner (overwriting other decorators, e.g. Java project decorator 'J') 
在所打开的项目中,右键项目名,选择“Add Spring Beans Project Nature”,这时该项目就会在右上角挂上了“S”. :)
Add references to other Spring projects
open project's properties dialog in Eclipse resource navigator or JDT package explorer 
 右键项目名,查看其properties,这就打开了"project properties"窗口
select the properties page "Project References" from the list 
 这时就可以选择 "Project References"
select Spring project(s) containing Spring Beans config files which are referenced from within in this project's Spring Beans config sets 
选择 所依赖引用的项目
Add Spring Beans factory config files
open project's properties dialog in Eclipse resource navigator or JDT package explorer or via double-clicking a project in the Spring Beans view
同样,再次打开项目的属性对话框,或者也可以打开“Spring Beans View”(这个窗口可以在window->slow view里面打开)
select the properties page "Spring Beans Project" from the list
在项目的属性窗口中选择"Spring Beans Project"
use button "Add..." to open a selector dialog and select all Spring Beans config files -> added Spring Beans config files are decorated with a small 'S' in the upper right corner
通过“Add”按钮选择Spring配置文件。
(optionally) combine config files into config sets with the second tab of the property page (use "New..." to create a new config set and select the config files; use "Move Up" and "Move Down" to change the order of the config files)
Open Spring Beans view
select from within any of the added Spring Beans config files opened in an Eclipse editor the menu item "Navigate/Show In/Spring Beans" -> Spring Beans view is opened and the corresponding Spring Beans config file is selected in the view's model
 Double clicking on an entry in the view navigates to the corresponding location in the config file
Validate Spring Beans config file
save any of the added Spring Beans config files from within an open Eclipse editor -> all errors occured during validation create a problem marker in Eclipse's task view
保存Spring配置文件,这时就可以看到错误了 (俺没有能够在task窗口中看到,但在Bean.xml文件的编辑窗口看到了,嘻嘻~~~)
另外,可以观察一下"Spring beans"那个窗口,在其上面有三个按钮,第三个是"show in property sheet", 这个功能不错哦,可以试一下。当然了,直接看xml文件也是挺好的。
6、非常好的一个功能,在Spring Beans那个窗口中添加好你的Spring配置文件之后,在其中右键你的配置文件,选择“show graph”,it's such a wonderful function~~~~
在线安装地址:  http://springframework.sourceforge.net/spring-ide/eclipse/updatesite/. 
注意哦,在安装的时候,一定要选“Spring framework”,然后才可以装“Spring IDE”(就是Beans Configuration Support啦。)
 
 
***************************************************************
SpringFuse, AppFuse的替代品?
SpringFuse ,从名字很容易让人联想到AppFuse 。与AppFuse类似,SpringFuse同样是一个项目构建工具,提供了新建项目的基础代码。不同的是,SpringFuse与 SpringSource是合作伙伴,SpringFuse提供的是在线服务,SpringFuse集中在Spring框架本身的一些功能 (SpringMVC, SpringWebFlow, Hibernate, Spring),没有像AppFuse那样提供多种框架组合的选择。
参考:
SpringFuse beta 2 released
SpringFuse快速入门
原文地址:https://www.cnblogs.com/huapox/p/3251488.html