struts.convention.result.path="/WEB-INF/content/": 结果页面存放的根路径,必须以 "/" 开头。
struts.convention.action.suffix="Action": action名字的获取
struts.convention.action.name.lowercase="true": 是否将Action类转换成小写
struts.convention.action.name.separator="-":
struts.convention.action.disableScanning="false": 是否不扫描类。
struts.convention.default.parent.package="convention-default":设置默认的父包。
struts.convention.package.locators="action,actions,struts,struts2": 确定搜索包的路径。
struts.convention.package.locators.disable="false":
struts.convention.package.locators.basePackage="":
写道
包命名习惯来指定Action位置
命名习惯制定结果(支持JSP,FreeMarker等)路径
类名到URL的约定转换
包名到命名空间(namespace)的约定转换
遵循SEO规范的链接地址(即:使用my-action 来替代 MyAction)
基于注解的Action名
基于注解的拦截机(Interceptor)
基于注解的命名空间(Nameespace)
基于注解的XWork包
默认action以及默认的结果(比如:/products 将会尝试寻找com.example.actions.Products 或 com.example.actions.products.Index进行处理)
struts2零配置详细可看这篇http://javeye.iteye.com/blog/358744
spring配置文件从外部加载properties文件
<!-- 定义易受环境影响的变量 -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="ignoreResourceNotFound" value="true" />
<property name="locations">
<list>
<!-- 标准配置 -->
<value>classpath*:/application.properties</value>
<!-- 本地开发环境配置 -->
<value>classpath*:/application.local.properties</value>
<!-- 服务器生产环境配置 -->
<value>file:/var/mini-service/application.server.properties</value>
</list>
</property>
</bean>
基于cxf集成spring开发webservice客户端技术 很简单:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
default-lazy-init="true">
<description>Apache CXF Web Service Client端配置</description>
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<jaxws:client id="userWebService" serviceClass="org.springside.examples.
miniservice.ws.UserWebService"
address="http://localhost:8080/mini-service/ws/userservice" />
</beans> <!--这个是webservice客现类接口-->
利用cxf本身API开发webservice 也很简单:
String address = BASE_URL + "/ws/userservice";
JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
proxyFactory.setAddress(address);
proxyFactory.setServiceClass(UserWebService.class);
//UserWebService是一个接口
UserWebService userWebServiceCreated = (UserWebService) proxyFactory.create();
//(可选)重新设定endpoint address.
((BindingProvider) userWebServiceCreated).getRequestContext()
.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
address);
利用velocity解释动态sql。不再需要为拼sql头痛了。
/**
* 使用Velocity生成内容的工具类.
*
* @author calvin
*/
public class VelocityUtils {
static {
try {
Velocity.init();
} catch (Exception e) {
throw new RuntimeException("Exception occurs while initialize the velociy.", e);
}
}
/**
* 渲染内容.
*
* @param template 模板内容.
* @param model 变量Map.
*/
public static String render(String template, Map<String, ?> model) {
try {
VelocityContext velocityContext = new VelocityContext(model);
StringWriter result = new StringWriter();
Velocity.evaluate(velocityContext, result, "", template);
return result.toString();
} catch (Exception e) {
throw new RuntimeException("Parse template failed.", e);
}
}
}
调用:
/**
* 使用Velocity创建动态SQL.
*/
public List<User> searchUserByFreemarkerSqlTemplate(Map<String, ?> conditions) {
String sql = VelocityUtils.render(searchUserSql, conditions);//searchUserSql由spring注入
logger.info(sql);
return jdbcTemplate.query(sql, userMapper, conditions);
}
<bean id="userJdbcDao" class="org.springside.examples.showcase.common.dao.UserJdbcDao">
<property name="searchUserSql">
<value><![CDATA[
SELECT id, name, login_name
FROM ss_user
WHERE 1=1
## Dynamic Content
#if ($loginName)
AND login_name=:loginName
#end
#if ($name)
AND name=:name
#end
ORDER BY id
]]></value>
</property>
</bean>
jdbcTeamplate 使用Bean形式命名参数
private static final String INSERT_USER = "insert into SS_USER(id, login_name, name) values(:id, :loginName, :name)";
//使用BeanPropertySqlParameterSource将User的属性映射为命名参数.
BeanPropertySqlParameterSource source = new BeanPropertySqlParameterSource(user);
jdbcTemplate.update(INSERT_USER, source);
webservice.利用mtom协义传传大文件
/**
* 演示以MTOM附件协议传输Streaming DataHandler的二进制数据传输的方式.
*
* @author calvin
*/
@XmlType(name = "LargeImageResult", namespace = WsConstants.NS)
public class LargeImageResult extends WSResult {
private static final long serialVersionUID = 8375875101365439245L;
private DataHandler imageData;
@XmlMimeType("application/octet-stream")
public DataHandler getImageData() {
return imageData;
}
public void setImageData(DataHandler imageData) {
this.imageData = imageData;
}
}
@WebService(serviceName = "LargeImageService", portName = "LargeImageServicePort", endpointInterface = "org.springside.examples.showcase.ws.server.LargeImageWebService", targetNamespace = WsConstants.NS)
public class LargeImageWebServiceImpl implements LargeImageWebService, ApplicationContextAware {
private static Logger logger = LoggerFactory.getLogger(LargeImageWebServiceImpl.class);
private ApplicationContext applicationContext;
/**
* @see LargeImageWebService#getImage()
*/
public LargeImageResult getImage() {
try {
//采用applicationContext获取Web应用中的文件.
File image = applicationContext.getResource("/img/logo.jpg").getFile();
//采用activation的DataHandler实现Streaming传输.
DataSource dataSource = new FileDataSource(image);
DataHandler dataHandler = new DataHandler(dataSource);
LargeImageResult result = new LargeImageResult();
result.setImageData(dataHandler);
return result;
} catch (IOException e) {
logger.error(e.getMessage(), e);
return WSResult.buildResult(LargeImageResult.class, WSResult.IMAGE_ERROR, "Image reading error.");
}
}
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
}
springside很强大,这些主流的大派对,这是不就是我们平常所要找的答案吗?很多技术因为没用,快忘记了,暂时作一个小笔记先。未完待续。。
分享到:
相关推荐
springSide3框架的笔记参照.pdf
springside-3.2.2源码springside-3.2.2源码
springside
SpringSide4.0 Reference Manual 自己整理的官方文档,PDF格式,方便查阅,所有连接都已整理。
springside4
springside3.0.zip
pom.xml配置 ...mvn install:install-file -DgroupId=org.springside -DartifactId=springside-core -Dversion=4.2.2.GA -Dfile=./springside-core-4.2.2.GA.jar -Dpackaging=jar -DgeneratePom=true
SpringSide文档.chm。
springside开发全面讲解 springside集成了多项技术,不适合入门者学习,因此本资料也尽量从最简单最基础的讲起。
分享 江南白衣的 springside4 非常强大的Javaee 框架。 官网:http://www.springside.org.cn/ 代码:https://github.com/springside/springside4
springside3.3.4 使用方法 ssh整合 最流行的web框架 使用说明
springside示例quickstart的eclipse工程
Springside4 学习整理 Shiro 服务端验证
springside-core-4.3.0.jar 最新版springside-core的jar包
SpringSide
springside3-core-3.3.4.jar,springside的3.3.4版本。
最近公司要求高maven+springside管理项目,凑合学,总结了一下
springside-joddform-2.0.zip
springside 案例 转换为myeclipse
springside3文档资料收录 calvin,游侠