不显示,在线等

ratevil 2010-01-25 11:12:33
<jsp:include page="context.jsp"></jsp:include>
<jsp:include page="../links.jsp"></jsp:include>
是写在index里的,context是个内容页面,需要从action里获取数据在跳到context页面,links是个友情链接的页面,也是从action里获取数据在跳到links里,我在测试的时候先测试的links页面,只在index里写了<jsp:include page="../links.jsp"></jsp:include>,结果在第一次加载的时候跑到了links页面,在刷新就到了index里,当我把<jsp:include page="context.jsp"></jsp:include>加在index里时,就报错了,Cannot forward after response has been committed,不是很懂,自己查了下,有的说mapping.findForward("context");return null;这样,可是还是报错,求高手指教!
...全文
283 14 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
蛋黄车 2010-01-25
  • 打赏
  • 举报
回复
你是用的struts1吧:

如果这两个页面都是从action中跳转过去的话,应该如下方法写,或者用绝对路径的方法

<jsp:include page="../cnrede/material/context.jsp"> </jsp:include>
<jsp:include page="../cnrede/link.jsp"> </jsp:include>
ratevil 2010-01-25
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 lrbyantai 的回复:]
根据你提供的信息,context.jsp页面的路径应该是webroot/cnrede/material/context.jsp

所以说你从action中跳到jsp页面的时候应该是page="../cnrede/material/context.jsp"

这样应该可以访问到
[/Quote]
我的错,没把页面之间的关系将清楚,webroot/cnrede/material/index.jsp是包含那2个include的页面,webroot/cnrede/material/context.jsp是内容页,webroot/cnrede/links.jsp是友情链接的页面,在struts里<forward name="context" path="/cnrede/material/context.jsp" />,走action了,但是跳不回去~
蛋黄车 2010-01-25
  • 打赏
  • 举报
回复
根据你提供的信息,context.jsp页面的路径应该是webroot/cnrede/material/context.jsp

所以说你从action中跳到jsp页面的时候应该是page="../cnrede/material/context.jsp"

这样应该可以访问到
ratevil 2010-01-25
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 lrbyantai 的回复:]
context.jsp路径有问题,因为你是从action中跳过去的,相对路径不正确

并且你说的刷新不可以,重新输入url访问一下
[/Quote]
<jsp:include page="${pageContext.request.contextPath }/cnrede/material/context.jsp"></jsp:include>我改成这样的话就更不会显示了,好像不让在include里放EL
ratevil 2010-01-25
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 z_fei 的回复:]
是不是context.jsp的路径写的有问题啊!是在webRoot下吗?加个“/”试试!
[/Quote]好像不是
蛋黄车 2010-01-25
  • 打赏
  • 举报
回复
context.jsp路径有问题,因为你是从action中跳过去的,相对路径不正确

并且你说的刷新不可以,重新输入url访问一下
Z_FEI 2010-01-25
  • 打赏
  • 举报
回复
是不是context.jsp的路径写的有问题啊!是在webRoot下吗?加个“/”试试!
蛋黄车 2010-01-25
  • 打赏
  • 举报
回复
O M G!

我犯了个错,web.xml里的配置信息呢?
ratevil 2010-01-25
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 lrbyantai 的回复:]
struts-config.xml
<forward name="contextMa" path="/cnrede/material/context.jsp" />

其它不改,把它换成index.jsp试下

[/Quote]
厉害!!成功了,呵呵,非常感谢!!!第一次这么玩,都把我整晕了。
蛋黄车 2010-01-25
  • 打赏
  • 举报
回复
struts-config.xml
<forward name="contextMa" path="/cnrede/material/context.jsp" />

其它不改,把它换成index.jsp试下
ratevil 2010-01-25
  • 打赏
  • 举报
回复
temolate1
1111
Hibernate: ***太长了,就删了,
url=contextMa
1111
2222
3333
temolate2
temolate3
ratevil 2010-01-25
  • 打赏
  • 举报
回复

index.jsp
<div class="zhong">
<%System.out.println("temolate1"); %>
<jsp:include page="context.jsp"></jsp:include>
<%System.out.println("temolate2"); %>
<jsp:include page="../links.jsp"></jsp:include>
<%System.out.println("temolate3"); %>
</div>


struts-config.xml
<forward name="contextMa" path="/cnrede/material/context.jsp" />
<forward name="contextMater" path="/cnrede/material/template.jsp" />


context.jsp
<%System.out.println("1111"); %>
<logic:notPresent name="recommendCs">
<jsp:forward page="/users.do?operate=doRecommendCompanys&type=contextMa"/>
</logic:notPresent>
<%System.out.println("2222"); %>
<logic:notPresent name="curUser">
<jsp:forward page="${pageContext.request.contextPath }/index.jsp"/>
</logic:notPresent>
<%System.out.println("3333"); %>
蛋黄车 2010-01-25
  • 打赏
  • 举报
回复
把你的配置文件贴出来看下,我想知道你的action是怎么配置的
ratevil 2010-01-25
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 lrbyantai 的回复:]
你是用的struts1吧:

如果这两个页面都是从action中跳转过去的话,应该如下方法写,或者用绝对路径的方法

<jsp:include page="../cnrede/material/context.jsp"> </jsp:include>
<jsp:include page="../cnrede/link.jsp"> </jsp:include>
[/Quote]
这样的话根本就访问不到那个context页面

81,116

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧