<struts> <!-- 这里面要做的是各种result类型 -->
<constant name="struts.devMode" value="true" /> <package name="default" namespace="/result" extends="struts-default"> <default-action-ref name="hello" /><!-- 默认状态下要转到的action -->
<action name="hello">
<result>/hello.jsp </result>
</action>
<action name="r1">
<result type="dispatcher">/r1.jsp</result>
</action>
<action name="r2">
<result type="redirect">/r2.jsp</result>
</action>
<action name="r3">
<result type="chain">r1</result>
</action>
<action name="r4">
<result type="redirectAction">r2</result>
</action>
</package>
</struts>hello.jsp文件是:
<body>
<a href="result/kkkkk/r1">dispatcher</a> <br/>
<a href="result/r2">redirect</a> <br/>
<a href="result/r3">chain</a> <br/>
<a href="result/r4">redirectAction</a> <br/>
</body>问题:
1.我在url中输入localhost:8080/TestResult回车,为什么显示不了hello.jsp页面,而把xml文件里的namespace改成namespace="/"就可以了?
2在namespace="/"的情况下,我点hello.jsp的第一个链接,明明我xml里没有result这个路径可是也能正确访问为什么吗?
求指点,谢谢。
<constant name="struts.devMode" value="true" /> <package name="default" namespace="/result" extends="struts-default"> <default-action-ref name="hello" /><!-- 默认状态下要转到的action -->
<action name="hello">
<result>/hello.jsp </result>
</action>
<action name="r1">
<result type="dispatcher">/r1.jsp</result>
</action>
<action name="r2">
<result type="redirect">/r2.jsp</result>
</action>
<action name="r3">
<result type="chain">r1</result>
</action>
<action name="r4">
<result type="redirectAction">r2</result>
</action>
</package>
</struts>hello.jsp文件是:
<body>
<a href="result/kkkkk/r1">dispatcher</a> <br/>
<a href="result/r2">redirect</a> <br/>
<a href="result/r3">chain</a> <br/>
<a href="result/r4">redirectAction</a> <br/>
</body>问题:
1.我在url中输入localhost:8080/TestResult回车,为什么显示不了hello.jsp页面,而把xml文件里的namespace改成namespace="/"就可以了?
2在namespace="/"的情况下,我点hello.jsp的第一个链接,明明我xml里没有result这个路径可是也能正确访问为什么吗?
求指点,谢谢。
解决方案 »
- 请问JAVA开发远程系统是否比C#更有优势?
- 在一个应用开发中出现的情况,java web与scoket登录的问题,求大牛提供解决方案,交流交流
- 关于Spring Security
- java调用linux命令的问题
- java中的model和数据库中的view怎么一一对应,就像java中的model和数据库中的表用*.hbm.xml对应起来
- org.hibernate.exception.GenericJDBCException: could not load an entity: [mypack.Customer#3]
- 关于tomcat访问问题
- (500分)关于用XML 适时与关系数据库 交换数据问题请教(up有分)
- please help me,appreciate it
- 有谁知道Eclipse2.1的JSP插件呀?知者给分哦
- glassfish连接数据源错误
- open flash chart多个柱形图问题
2、能访问是因为你配了 <default-action-ref name="hello" /><!-- 默认状态下要转到的action -->
你自己写的很清楚了,如果访问的路经不正确,会调用默认的action来转到你事先定义好的逻辑。
第2个是r1.jsp。我的疑问是:在hello.jsp能正常访问的情形下,result/r1.它会访问r1这个result里的r1.jsp。但是我要把链接路径改为reult/kkk/kk/r1它也能正常访问到r1.jsp,这是为什么呀
谢谢
第一个你如果是/result 只有/result他才会去跳转ACTION 如果是/ 的话 /TestResult 他就会就跳转action 里面没有配置 所有就跳转默认的hello.jsp第二是能访问hello.jps 还是r1.jsp我的意思是namespace里面配置namespace="/result",我在url里面输入localhost:8080/TestResult,是为了验证它能访问hello.jsp.但是xml里面没有namespace="/"是不是就不能访问到hello.jsp呀。我在url里面输入localhost:8080/TestResult/result.也不能访问到hello.jsp.
第2个是r1.jsp。我的疑问是:在hello.jsp能正常访问的情形下,result/r1.它会访问r1这个result里的r1.jsp。但是我要把链接路径改为reult/kkk/kk/r1它也能正常访问到r1.jsp,这是为什么呀
谢谢
谢谢