requestWrapper.addHeader("realm","test")
说这个类的对象是servlet container创建,作为参数传给servlet的service的。也就是说这个对象的生命周期都是发生在服务端的,所以如果需要把什么东西传递给servlet,完全没有必要通过header的方式。貌似在response里setheader给客户端才有意义,在request里还真没遇到过。如果非要在这个对象里set点什么东西,他的父类,ServletRequest,有setAttribute方法,可以参考。
另外:翻了半天HttpServletRequest的原码,没翻到,只找到接口定义。但是个人分析,HttpServletRequest的header应该跟父类的attribute有关,如果能找到getHeader方法的原码,或许能分析出怎么set一个header。
Apache Camel的Header、Property、Body配置示例
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="echo" class="com.lala.bean.Echo"></bean>
<bean id="bean1" class="com.lala.bean.Bean1"></bean>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route autoStartup="true">
<from uri="timer://aaa?fixedRate=true&period=60000" />
<process ref="bean1"/>
<!-- 设置所有的headers(会去掉之前的所有header) -->
<setOutHeader headerName="name">
<constant>白展堂</constant>
</setOutHeader>
<!-- 添加一个header -->
<setHeader headerName="id">
<constant>100010</constant>
</setHeader>
<!-- 设置property -->
<setProperty propertyName="type">
<simple>${in.header.id}</simple>
</setProperty>
<!-- 设置body -->
<setBody>
<simple>name:${in.header.name},type:${property.type}</simple>
</setBody>
<process ref="echo"/>
</route>
</camelContext>
</beans>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)