java httpinvoker漏洞_spring httpinvoker 例子

吕德业
2023-12-01

1,创建接口:

public interface HttpInvokerTestI {

public TestPo getTestPo(String desp);

}

实现:

public class HttpInvokertestImpl implements HttpInvokerTestI {

@Override

public TestPo getTestPo(String desp) {

// TODO Auto-generated method stub

return new TestPo(desp);

}

}

配置:在web info下添加remote-servlet.xml

内容:

添加spring.jar spring-webmvc.jar(配置dispacherServlet用)

web.xml 添加对context和servlet的支持:

contextConfigLocation

classpath:applicationContext-*.xml

org.springframework.web.context.ContextLoaderListener

remote

org.springframework.web.servlet.DispatcherServlet

1

remote

/remoting/*

客户端配置:

class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">

value="http://localhost:8080/ssh/remoting/hit" />

测试类:

public static void main(String[] args) {

ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext-bean.xml");

HttpInvokerTestI httpInvokerTestI = (HttpInvokerTestI) context.getBean("remoteService");

System.out.println(httpInvokerTestI.getTestPo("dddd").getDesp());

}

完成。

 类似资料: