本文介绍了substring(0,9)给我空指针异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,

好​​像虽然这个空指针不会让我安静地回家!!!!

i有一个jsp页面,我做一个get属性就像这--->

[HTML]<%String s24 =(String)request.getAttribute(" s24"); %> [/ HTML]

并且要检索值我做这样的事情--->

[HTML]<%= s24.substring( 0,9)%> [/ HTML]

但是方法substring(0,9)给了我一个空指针异常。我可以避免或者更确切地消除这种异常/错误吗?请指导我这个:)。

问候,

ajos

hi friends,
seems as if though this null pointers wont let me go peacefully home!!!!
i have a jsp page where i do a get attribute like this--->
[HTML]<%String s24=(String) request.getAttribute("s24"); %>[/HTML]
and to retrieve the value i do some thing like this--->
[HTML]<%=s24.substring(0,9) %>[/HTML]
but the method substring(0,9) is giving me a null pointer exception. have can i avoid or rather eliminate this exception/error?? please guide me regarding this:).
regards,
ajos

推荐答案



字符串s24为空。这意味着名为s24的属性从未传递给JSP。它应该来自哪里? servlet?

The string s24 is null. That means the attribute called s24 was never passed to the JSP. Where is it supposed to come from? A servlet?




hi r035198x,

感谢你的回复。我做的就是在我的servlet --->

hi r035198x,
thanks for your reply yet again.wat i did was in my servlet--->

展开 | 选择 | Wrap | 行号


展开 | 选择 | Wrap | 行号


这篇关于substring(0,9)给我空指针异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 07:36