服务器端配置和代码
pom 配置
com.caucho
hessian
4.0.38
web.xml 配置
hessian-servlet
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:hessian-servlet.xml
1
hessian-servlet
/remoting/*
org.springframework.web.context.ContextLoaderListener
contextConfigLocation
classpath:applicationContext-base.xml
编写接口
public interface UserInfo {
String GetUser(int userid);
}
实现类
@Component("userInfoImplRome")
public class UserInfoImpl implements UserInfo {
public String GetUser(int userid) {
// TODO Auto-generated method stub
return userid+"ss";
}
}
hessian接口注册
hessian-servlet.xml
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd">
服务器端的配置和简单的代码完成
客户端配置和代码
spring 配置
Controller 调用
@Controller public class OrderInfo { @Resource(name="userClientService") private UserInfo userClientService; @RequestMapping("getorder") @ResponseBody public String GetOrder(){ System.out.println(userClientService.GetUser(7788)); return "98568564546546"; } }