新手的问题啊~~小弟初学flex4需要到一个问题就是spring的调用问题。我的项目是SSH整合想用flex调用spring,听说官方出了一个注解
@Service("userInfoBIZImpl")
@RemotingDestination(channels={"my-amf"})
我就使用了,这是我业务的类
import javax.annotation.Resource;import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.flex.remoting.RemotingInclude;
import org.springframework.stereotype.Service;
import com.byyd.biz.UserInfoBIZ;
import com.byyd.dao.UserInfoDAO;
import com.byyd.entity.UserInfo;
@Service("userInfoBIZImpl")
@RemotingDestination(channels={"my-amf"})
public class UserInfoBIZImpl implements UserInfoBIZ {
@Resource
private UserInfoDAO userInfoDAO; @RemotingInclude
public UserInfo userLogin(String loginName, String password) {
// TODO Auto-generated method stub
UserInfo u=userInfoDAO.getUser(loginName);
if (u!=null&&u.getPassword().equals(password)) {
System.out.println("ok");
return u;
}else {
System.out.println("no");
return null;
}
}
}
services-config.xml文件<?xml version="1.0" encoding="UTF-8"?>
<services-config> <services>
<service-include file-path="remoting-config.xml" />
<service-include file-path="proxy-config.xml" />
<service-include file-path="messaging-config.xml" />
<default-channels>
<channel ref="my-amf" />
</default-channels>
</services> <security>
<login-command class="flex.messaging.security.TomcatLoginCommand" server="Tomcat"/>
</security> <channels> <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
</channel-definition> <channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel">
<endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/>
<properties>
<add-no-cache-headers>false</add-no-cache-headers>
</properties>
</channel-definition> <channel-definition id="my-polling-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/>
<properties>
<polling-enabled>true</polling-enabled>
<polling-interval-seconds>4</polling-interval-seconds>
</properties>
</channel-definition> </channels> <logging>
<target class="flex.messaging.log.ConsoleTarget" level="Error">
<properties>
<prefix>[BlazeDS] </prefix>
<includeDate>false</includeDate>
<includeTime>false</includeTime>
<includeLevel>false</includeLevel>
<includeCategory>false</includeCategory>
</properties>
<filters>
<pattern>Endpoint.*</pattern>
<pattern>Service.*</pattern>
<pattern>Configuration</pattern>
</filters>
</target>
</logging> <system>
<redeploy>
<enabled>false</enabled>
</redeploy>
</system></services-config>
但是我在flex怎么也调用不出来·我估计是我的flex页面调用不对·我希望有谁能给我一个小例子。是flex+Spring的··可以不用要数据库。 ,小弟跪求一份,谢谢^_^
@Service("userInfoBIZImpl")
@RemotingDestination(channels={"my-amf"})
我就使用了,这是我业务的类
import javax.annotation.Resource;import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.flex.remoting.RemotingInclude;
import org.springframework.stereotype.Service;
import com.byyd.biz.UserInfoBIZ;
import com.byyd.dao.UserInfoDAO;
import com.byyd.entity.UserInfo;
@Service("userInfoBIZImpl")
@RemotingDestination(channels={"my-amf"})
public class UserInfoBIZImpl implements UserInfoBIZ {
@Resource
private UserInfoDAO userInfoDAO; @RemotingInclude
public UserInfo userLogin(String loginName, String password) {
// TODO Auto-generated method stub
UserInfo u=userInfoDAO.getUser(loginName);
if (u!=null&&u.getPassword().equals(password)) {
System.out.println("ok");
return u;
}else {
System.out.println("no");
return null;
}
}
}
services-config.xml文件<?xml version="1.0" encoding="UTF-8"?>
<services-config> <services>
<service-include file-path="remoting-config.xml" />
<service-include file-path="proxy-config.xml" />
<service-include file-path="messaging-config.xml" />
<default-channels>
<channel ref="my-amf" />
</default-channels>
</services> <security>
<login-command class="flex.messaging.security.TomcatLoginCommand" server="Tomcat"/>
</security> <channels> <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
</channel-definition> <channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel">
<endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/>
<properties>
<add-no-cache-headers>false</add-no-cache-headers>
</properties>
</channel-definition> <channel-definition id="my-polling-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/>
<properties>
<polling-enabled>true</polling-enabled>
<polling-interval-seconds>4</polling-interval-seconds>
</properties>
</channel-definition> </channels> <logging>
<target class="flex.messaging.log.ConsoleTarget" level="Error">
<properties>
<prefix>[BlazeDS] </prefix>
<includeDate>false</includeDate>
<includeTime>false</includeTime>
<includeLevel>false</includeLevel>
<includeCategory>false</includeCategory>
</properties>
<filters>
<pattern>Endpoint.*</pattern>
<pattern>Service.*</pattern>
<pattern>Configuration</pattern>
</filters>
</target>
</logging> <system>
<redeploy>
<enabled>false</enabled>
</redeploy>
</system></services-config>
但是我在flex怎么也调用不出来·我估计是我的flex页面调用不对·我希望有谁能给我一个小例子。是flex+Spring的··可以不用要数据库。 ,小弟跪求一份,谢谢^_^
<mx:RemoteObject id="dao" destination="gpsProcessService" >
<mx:method name="save" result="addResultHandle(event)" />
</mx:RemoteObject>在flex某个方法调用方法保存对象:
public function okhandler(evt:CloseEvent):void{
var obj:GpsDeviceVO=new GpsDeviceVO();
obj.name="test";
dao.save(obj);
//保存后 离开
}
}建立java和flex的model类:
先看看java的:public class GpsDeviceVO {
private String name;public void setName(String name) {
this.name= name;
}public String getName() {
return name;
}
}再看看flex的:
[Bindable] [RemoteClass(alias="com.tour.gps.VO.GpsDeviceVO")] //这里是关联java的model类public class GpsDeviceVO { public var name:String; }最后就是调用方法的java类:public String save(GpsDeviceVO obj){
try {
BaseDAO.save(obj);
} catch (FrameworkException e) {
return e.toString();
}
return null; }已经完成了~~记得要关联java实体类~~