如何在jsp页面上避免null [英] how to avoid null on a jsp page

查看:145
本文介绍了如何在jsp页面上避免null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


请查看以下jsp页面代码,此页面加载时为null正在印刷。请建议我在哪里做错了。还添加了Servlet代码以获取更多详细信息。

Page: javatest.jsp

展开 | 选择 | Wrap | 行号

解决方案

在servlet中,应该在转发请求或调用requestDispatcher之前调用request.setAttribute。 / blockquote>


在您的servlet中,您应该在转发请求或调用requestDispatcher之前调用request.setAttribute。





谢谢,我试过这个,但结果仍然一样。问题仍然存在。我们可能需要其他东西来解决这个问题


是否始终从该servlet调用该JSP?如果没有,那么该属性将无法在JSP中使用,因为它来自servlet。


hi,
Please have a look at the following jsp page code , when this page gets loaded "null" is being printed. Please suggest me where i am doing wrong. Servlet code is also added for more details.

Page: javatest.jsp

Expand|Select|Wrap|Line Numbers

解决方案

In your servlet, you should call request.setAttribute before forwarding the request or calling the requestDispatcher.


In your servlet, you should call request.setAttribute before forwarding the request or calling the requestDispatcher.

Hi,
Thank you, I have tried this but the result remains same. Problem still exists. We may require something else to resolve this issue


Is that JSP always called from that servlet? If not then that attribute will not be available i the JSP since it''s coming from the servlet.


这篇关于如何在jsp页面上避免null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆