首页 / 软件开发 / JAVA / Struts2 redirectAction转向时默认加pass的问题
Struts2 redirectAction转向时默认加pass的问题2010-12-22 javaeye 飞雪无情项目中要转发action,我就用Xml代码<result name="success" type="redirectAction">my.action</result>但是今天再用的时候发现一个莫名其名的问题,程序转向了一个不存在的url ,如下:原来应该是这样的:http://localhost:8080/focus/account/my.action其中focus,是项目名,就是上下文路径,account是命名空间,my.action是 我的action。这样才是对的,可是今天的url却是 http://localhost:8080/focus/pass/account/my.action!pass由于根本不存在这样的url,就提示404错误。。调试了很久才发现是加入了JCR170的问题,jcr170的bean文件不愤如下:Xml代码<bean id="jcrSessionFactory" class="org.springmodules.jcr.JcrSessionFactory">
<property name="repository" ref="repository"/>
<property name="credentials">
<bean class="javax.jcr.SimpleCredentials">
<constructor-arg index="0" value="bogus"/>
<!-- create the credentials using a bean factory -->
<constructor-arg index="1">
<bean factory-bean="password"
factory- method="toCharArray"/>
</constructor-arg>
</bean>
</property>
<!-- register some bogus namespaces -->
<!--
<property name="namespaces">
<props>
<prop key="foo">http://bar.com/jcr</prop>
<prop key="hocus">http://pocus.com/jcr</prop>
</props>
</property>
-->
<!-- register a simple listener
<property name="eventListeners">
<list>
<bean class="org.springmodules.jcr.EventListenerDefinition">
<property name="listener">
<bean class="org.springmodules.examples.jcr.DummyEventListener"/>
</property>
</bean>
</list>
</property>
-->
</bean>
<!-- create the password to return it as a char[] -- >
<bean id="password" class="java.lang.String">
<constructor-arg index="0" value="pass"/>
</bean>上面就是关键代码,id为password的值是pass,就是他跑到struts2的 redirectAction里面!目前具体原因不明,不过有解决方法,就是把<!-- create the password to return it as a char[] -->
<bean id="password" class="java.lang.String">
<constructor-arg index="0" value="pass"/>
</bean>注释掉,然后修改:<constructor-arg index="1">
<bean factory-bean="password" factory- method="toCharArray"/>
</constructor-arg>为:<constructor-arg index="1" value="pass"/>就行了!!如果有知道原因的说一下,感激不尽!!