加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

【转】java:“String index out of range: 0”

(2015-07-11 13:34:58)
分类: 工作手记

可能是出现了某行为空


Let's check what ViewHandlerImpl#getActionURL() does (Mojarra is just open source). Here's is a summarized/stripped extract of the method as it is in Mojarra 2.0.2:


public String getActionURL(FacesContext context, String viewId) {
    if (context == null) throw new NullPointerException();
    if (viewId == null) throw new NullPointerException();
    if (viewId.charAt(0) != '/') throw new IllegalArgumentException();
    // ...

In other words, the passed-in viewId is an empty string instead of null or / or the normal path. The Mojarra viewhandler didn't expect it at all, hence this runtime exception. It can be a bug in the view handler of Mojarra that it should handle empty strings as well, but it can also be a bug in the view handler of either Ajax4jsf, Facelets or Seam that it should never pass an empty string through up. It can also be a bug in your own code that you're actually passing an empty string as view ID.

If the problem isn't in your code, then I would start with upgrading what can be upgraded to see if it resolves the problem. Maybe it was already reported before as a bug and fixed in a newer release. If that doesn't help, I would check the classpath for duplicate JAR files of different versions which might have collided with each other.

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有