标签存档:spring
flex+BlazeDS与spring集成
发表时间:18. Dec, 2009 作者:Freddie.
本文基本上就是Christophe Coenraets 先生的 Using Flex with Spring 的翻译版本,加上了自己的注解便于理解
首先,你得有一个SpringFactory.java类。去网上找,没有的话留下邮箱我发给你们~
1.新建一个工程,服务器端选用j2ee,跟建立blazeDS一样~ 配置好路径,加入web容器支持和spring容器支持~(这一步比较简单,详细步骤就省了~)
2.现在我们来写hello world~ 首先在src下写一个HelloWorld.java,我的路径是com.tub.HelloWorld.java
public class HelloWorld {
public String message(String str){
return str;
}
}
3.然后是flex端~
<mx:RemoteObject id=”ro” destination=”MessageService”/>
<mx:TextInput id=”ta”/>
<mx:Button label=”Button” click=”ro.message(String(ta.text))”/>
<mx:Label text=”{ro.message.lastResult}”/>
注:ro当然就指的是HelloWorld了,destination指定的内容是我们需要在WEB-INF/flex/remoting-config.xml中配置的destination了,它会指定一个具体对应的类或者是spring工厂~(我们这里当然是交给spring工厂拉)
4.代码都写好了,我们现在要对spring进行配置了~~
把SpringFactory放在java目录下,我的路径是com.tub.spring
然后,我们需要在web.xml中加入
<context-param>
<param-name>spring</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
最后,我们还需要对flex的service-config.xml进行配置,加入
<factories>
<factory id=”spring” />
</factories>
好了,大功告成拉~ 赶快去deploy了运行看看吧~
详细内容
Spring中常用的hql查询方法(getHibernateTemplate())(转)
发表时间:13. Dec, 2009 作者:Freddie.
一、find(String queryString);
示例:this.getHibernateTemplate().find(“from bean.User”);
返回所有User对象
二、find(String queryString , Object value);
示例:this.getHibernateTemplate().find(“from bean.User u where u.name=?”, “test”);
或模糊查询:this.getHibernateTemplate().find(“from bean.User u where u.name like ?”, “%test%”);
返回name属性值为test的对象(模糊查询,返回name属性值包含test的对象)
三、find(String queryString, Object[] values);
示例:String hql= “from bean.User u where u.name=? and u.password=?”
this.getHibernateTemplate().find(hql, new String[]{“test”, “123″});
返回用户名为test并且密码为123的所有User对象
---------------------------------
四、findByExample(Object exampleEntity)
示例:
User u=new User();
u.setPassword(“123″);//必须 符合的条件但是这两个条件时并列的(象当于sql中的and)
u.setName(“bb”);
list=this.getHibernateTemplate().findByExample(u,start,max);
返回:用户名为bb密码为123的对象
五、findByExample(Object exampleEntity, int firstResult, int [...]

