读书人

Struts中的Action二次请求不认路径./的

发布时间: 2012-10-29 10:03:53 作者: rapoo

Struts中的Action二次请求不认路径../的解决方法

地址栏没有了项目名称:http://localhost:8088/searchBuildingInfo.do?method=searchBuildingInfo2
报错:
Apache Tomcat/6.0.13 - Error report<h1 font-familytahomaarialsans-serifcolorwhitebackground-colordfont-sizepx h font-familytahomaarialsans-serifcolorwhitebackground-colordfont-sizepx h font-familytahomaarialsans-serifcolorwhitebackground-colordfont-sizepx body font-familytahomaarialsans-serifcolorblackbackground-colorwhite b font-familytahomaarialsans-serifcolorwhitebackground-colord p font-familytahomaarialsans-serifbackgroundwhitecolorblackfont-sizepxa color blackaname color blackhr color d-->--<

HTTP Status 404 - /searchBuildingInfo.do

type Status report

message /searchBuildingInfo.do

description The requested resource (/searchBuildingInfo.do) is not available.

Apache Tomcat/6.0.13

<!--从管理员页面查询进入searchhouseinfo.jsp页面后使用相同的:-->
<ahref="http://jeromecen1021.blog.163.com/blog/../searchBuildingInfo.do?method=searchBuildingInfo2">更多楼盘信息</a>型路径出错。
<!--项目布局如下:-->

Struts中的Action二次请求不认路径./的解决办法

?解决办法:这样的问题猜想是struts中的path路径或代码中变量名称的错误,后面将:
<a href="http://jeromecen1021.blog.163.com/blog/../searchBuildingInfo.do?method=searchBuildingInfo2">更多楼盘信息</a>
后面尝试改为了:
?<ahref="http://jeromecen1021.blog.163.com/blog/${pageContext.request.contextPath}/searchBuildingInfo.do?method=searchBuildingInfo2">更多楼盘信息</a>
或者使用项目名称绝对路径,都是无法解决。
最后是将其改为:
<html:link page="/searchBuildingInfo.do?method=searchBuildingInfo2">更多楼盘信息</html:link>
将问题解决,为何第一次action跳转使用../path.do?可以实现跳转,而跳转后再使用就无法实现正确的解析action路径?那是因为struts用do请求跳转后第二次不能处理../的缘故。
这时改用struts标签可以从跳转后的文件夹里面的jsp文件实现正确的解析actio路径。

当然合理的使用/Unity3dHouse4/${pageContext.request.contextPath}/**.do?还是可以实现的。

读书人网 >编程

热点推荐