Hessian探究(一)Hessian与springMVC结合
来源:互联网 发布:java解析json数组数据 编辑:程序博客网 时间:2024/06/08 14:27
上一篇博客Hessian探究(一)Hessian入门示例我们初步简单的介绍了一下Hessian的使用入门示例,我们是通过Servlet来暴露Hessian的对外服务的,接下来我们介绍一下通过SpringMVC的方式来暴露Hessian的对外调用服务
(1)在springMVC的配置文件springmvc-config.xml中进行配置,类似一个普通的Controller,这样我们就可以通过连接来访问Controller了,Hessian和springMVC结合也是类似这样。这样对外暴露的连接就是http://localhost/hessian.action了。
<bean id="helloService" class="com.tianjunwei.hessian.server.HelloServiceImpl" /> <!-- 使用Spring的HessianServie做代理 --> <bean name="/hessian.action" class="org.springframework.remoting.caucho.HessianServiceExporter"> <!-- service引用具体的实现实体Bean--> <property name="service" ref="helloService" /> <property name="serviceInterface" value="com.tianjunwei.hessian.server.HelloService" /> </bean>(2)客户端就可以访问Hessian使用springMVC暴露的服务。
package com.tianjunwei.hessian.client;import java.net.MalformedURLException;import com.caucho.hessian.client.HessianProxyFactory;import com.tianjunwei.hessian.server.HelloService;public class HelloServiceControllerMain {public static void main(String [] args) throws MalformedURLException{String url = "http://localhost/hessian.action"; System.out.println(url); HessianProxyFactory factory = new HessianProxyFactory(); HelloService helloService = (HelloService) factory.create(HelloService.class, url); System.out.println(helloService.helloWorld("world"));}}运行结果:
hello,world
0 0
- Hessian探究(一)Hessian与springMVC结合
- Hessian探究(一)Hessian与Spring结合
- Hessian探究(一)Hessian入门示例
- hessian与spring的结合
- hessian(一)
- Hessian
- hessian
- Hessian
- Hessian
- hessian
- Hessian
- Hessian
- Hessian
- Hessian
- Hessian
- Hessian
- Hessian
- Hessian
- jeecg 添加自定义标签
- Failed with exception Unable to move source hdfs://maeter:8000/usr/local/hadoop/input/test_hive/test
- Shader博客学习转载 - shader实例(一)帧序列动画
- Windows 10无限蓝屏
- 高频率调用的函数一定要保证最优化,慎用除法和余数
- Hessian探究(一)Hessian与springMVC结合
- 轻松实现广告头效果
- SharpNL Stem&Tokenize
- 发布一个软件,需要多少人?
- SqlServer 2008R2 无法远程连接的解决办法
- 图片路径获取问题
- Java中线程同步
- openfalcon-mongodb监控插件
- linux比较文件命令-diff