消息关闭
    暂无新消息!
错误提示
HTTP Status 500 - An exception occurred processing JSP page /NewsContent.jsp at line 53


type Exception report

message An exception occurred processing JSP page /NewsContent.jsp at line 53

description The server encountered an internal error that prevented it from fulfilling this request.

exception 
org.apache.jasper.JasperException: An exception occurred processing JSP page /NewsContent.jsp at line 53

50:      ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
51:  NewsService newsService = (NewsService) ac.getBean("NewsService");
52:  String id = (String)session.getAttribute("newsId");
53:  News news = newsService.getNews(Integer.parseInt(id));
54: 
55:  int length = news.getContent().length()*3/4+20;
56: 


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)



root cause 
java.lang.NumberFormatException: null
java.lang.Integer.parseInt(Integer.java:542)
java.lang.Integer.parseInt(Integer.java:615)
org.apache.jsp.NewsContent_jsp._jspService(NewsContent_jsp.java:120)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)



note The full stack trace of the root cause is available in the Apache Tomcat/7.0.47 logs.

源码
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*" %>
<%@ page import="org.springframework.context.ApplicationContext"%>
<%@ page import="org.springframework.context.support.ClassPathXmlApplicationContext"%>
<%@ page import="com.lt.News.model.News"%>
<%@ page import="com.lt.News.service.NewsService"%>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>显示新闻</title>

<style>
body{ background-color:#FFFFFF}
#content{ width:900px; margin:0 auto;}
#top{width:100%; height:140px; margin:0 auto; background-color:#f8f8f8; background-image:url(logo.png); background-position:50% 0; background-repeat:no-repeat;}
#news{ width:606px; float: left; border-top:1px  #999999 solid; background-color:#FFFFFF}
#news h2{ text-align:center}
#news .nag{ width:100%; height:45px; background-image:url(daohang.png);background-repeat:no-repeat; background-position:center; font-size:12px; line-height:43px;}
#news .nag .time{margin-left:30px; width:125px; float:left; color:#8b8b8b;}
#news .nag .type{ margin-left:29px; width:60px;   float:left; color:#8b8b8b;}
#news .nag .author{ margin-left:27px; width:70px; float:left; color:#8b8b8b;}
#news .nag .share{ margin-left:23px; width:40px;  float:left; color:#8b8b8b;}
#news .nag .click{ margin-left:110px; width:45px; float:left; text-align:center; color:#5987f1; font-size:25px; font-weight:bold;}
#news .nag .enter{ margin-left:4px; width:38px; float:left; text-align:center; text-align:center; color:#FFFFFF;}
#news .zw{ width:100%}
#news .pl{ width:100%; height:226px; background-image:url(pinglun.png); border-left:1px  #999999 solid; border-right:1px  #999999 solid;}
#news .pl textarea{ margin-left:90px; margin-top:-4px; width:483px; height:94px; }
#news .pl p{ margin-left:520px; margin-top:0px;  font-size:12px; }
#news .pl p span{ color:#FF0000; font-size:18px; font-weight:bold;}
#news .pl input{ margin-left:335px; width:150px; height:33px; margin-top:-1px; font-size:16px;float:left;}
#news .pl .publish{ width:90px; height:38px; margin-left:-1px;  font-size:16px; line-height:38px; text-align:center; color:#FFFFFF; font-weight:bold;
 background-color:#0099FF;}
#news .discuss{ width:100%;border-left:1px  #999999 solid; border-bottom:1px  #999999 solid; border-right:1px  #999999 solid; border-top:1px dashed #999999;}
#news .discuss h4{ margin-left:20px; color:#0099FF;}
#news .discuss .content{ width:100%;}
#news .discuss .content .name{margin-left:20px; color:#0099FF; float:left;}
#news .discuss .content .time{margin-left:420px; width:180px; height:30px; }
#news .discuss .content .words{ width:566px; margin-left:20px;border-bottom:1px  #999999 dashed;}
#buttom1{ width:900px; height:100px; margin-top:-1px; margin-left:auto; margin-right:auto; background-color:#f8f8f8;}
#buttom2{ width:900px; height:30px; margin:0 auto; background-color:#000000; line-height:30px; color:#FFFFFF; text-align:center; }
#guanggao{width:275px; height:250px;  float:right; border:3px  #999999 solid; line-height:250px; text-align:center; color:red; font-weight:bold; font-size:40px;}
.textwidget{width:0px;float:right; margin-top:280px;}
</style>

</head>
<body>
<% 
50     ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
51 NewsService newsService = (NewsService) ac.getBean("NewsService");
52 String id = (String)session.getAttribute("newsId");
53 News news = newsService.getNews(Integer.parseInt(id));

int length = news.getContent().length()*3/4+20;

//取出评论内容
String discuss = newsService.getNews(Integer.parseInt(id)).getDiscuss();
//评论数
int disNum = 0; 
String[] diss = null;
if(!discuss.equals(""))
{
diss = discuss.split("~");
disNum = diss.length;
}
%>
<div id="content">
<div id="top"></div>
<div id="news">
<h2><%=news.getTitle() %></h2>

<div class="nag">
<div class="time"><%=news.getPudate() %></div>
<div class="type"><%=news.getType() %></div>
<div class="author"><%=news.getAuthor() %></div>
<div class="share"><a href="#">分享</a></div>
<div class="click"><%=news.getClick() %></div>
<div class="enter"><a href="#pl">参与</a></div>
</div>

<div class="zw">
<textarea readonly="readonly" style="width:99%; height:<%=length%>px;border:0px;font-size:14px;"><%=news.getContent() %></textarea>
</div>

<div class="pl">&nbsp;
<p><span><%=disNum %></span> 条评论</p>
<form  action="DiscussServlet" method="post">
<textarea name="discuss" cols="66" rows="6"></textarea>
<input type="text" name="name" placeholder="壮士,请赏个姓名吧!"/>
<input class="publish"  type="submit" value="提交"/>
</form>
</div>

<div class="discuss">
<h4>热门评论</h4>
<%
for(int i=0; i<disNum; i++)
{
//继续拆分
String[] str = diss[i].split("%");
String name = str[0];
String time = str[1];
String dis = str[2];
System.out.println(name + time + dis);

%>
<div class="content">
<div class="name"><%=name %></div>
<div class="time"><%=time %></div>
<div class="words">&nbsp;<%=dis %></div>
</div>
<%} %>
</div>
<br/>


<div id="buttom1"></div>
<div id="buttom2">第七组</div>
</div>

<div id="guanggao">广告位招租!</div>
<div class="textwidget"><script type="text/javascript">
    var cpro_id = "u2112317";
</script>
<script src="http://cpro.baidustatic.com/cpro/ui/c.js" type="text/javascript"></script><div id="BAIDU_DUP_wrapper_u2112317_0"><iframe id="cproIframe_u2112317_7" width="300" height="250" src="http://pos.baidu.com/acom?adn=3&amp;at=231&amp;aurl=&amp;cad=1&amp;ccd=24&amp;cec=UTF-8&amp;cfv=18&amp;ch=0&amp;col=zh-CN&amp;conBW=0&amp;conOP=1&amp;cpa=1&amp;dai=7&amp;dis=0&amp;ltr=http%3A%2F%2Fwww.nruan.com%2Fwin-key.html&amp;ltu=http%3A%2F%2Fwww.nruan.com%2F&amp;lu_161=0&amp;lunum=6&amp;n=68029130_cpr&amp;pcs=1347x643&amp;pis=10000x10000&amp;ps=3110x1028&amp;psr=1366x768&amp;pss=1347x5630&amp;qn=0da09fb18e2d768a&amp;rad=&amp;rsi0=300&amp;rsi1=250&amp;rsi5=4&amp;rss0=%23FFFFFF&amp;rss1=%23FFFFFF&amp;rss2=%230000ff&amp;rss3=%23444444&amp;rss4=%23008000&amp;rss5=&amp;rss6=%23e10900&amp;rss7=&amp;scale=&amp;skin=tabcloud_skin_3&amp;stid=5&amp;td_id=2112317&amp;titFF=%E5%AE%8B%E4%BD%93&amp;titFS=12&amp;titTA=left&amp;tn=text_default_300_250&amp;tpr=1436888793184&amp;ts=1&amp;version=2.0&amp;xuanting=0&amp;dtm=BAIDU_DUP2_SETJSONADSLOT&amp;dc=2&amp;di=u2112317&amp;ti=Nruan.com%20%7C%20N%E8%BD%AF%E7%BD%91%20%7C%20%E5%B1%B9%E7%AB%8B%E5%9C%A8IT%E5%89%8D%E6%B2%BF&amp;tt=1436888793153.57554.57678.57679" align="center,center" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" allowtransparency="true"></iframe></div><script charset="utf-8" src="http://pos.baidu.com/acom?di=u2112317&amp;dcb=BAIDU_DUP2_define&amp;dtm=BAIDU_DUP2_SETJSONADSLOT&amp;dbv=2&amp;dci=0&amp;dri=0&amp;dis=0&amp;dai=7&amp;dds=&amp;drs=1&amp;dvi=1432188695&amp;ltu=http%3A%2F%2Fwww.nruan.com%2F&amp;liu=&amp;ltr=http%3A%2F%2Fwww.nruan.com%2Fwin-key.html&amp;lcr=&amp;ps=3110x1028&amp;psr=1366x768&amp;par=1366x728&amp;pcs=1347x643&amp;pss=1347x5630&amp;pis=-1x-1&amp;cfv=18&amp;ccd=24&amp;chi=4&amp;cja=true&amp;cpl=6&amp;cmi=8&amp;cce=true&amp;col=zh-CN&amp;cec=UTF-8&amp;cdo=-1&amp;tsr=57538&amp;tlm=1436888850&amp;tcn=1436888851&amp;tpr=1436888793184&amp;dpt=none&amp;coa=&amp;ti=Nruan.com%20%7C%20N%E8%BD%AF%E7%BD%91%20%7C%20%E5%B1%B9%E7%AB%8B%E5%9C%A8IT%E5%89%8D%E6%B2%BF&amp;baidu_id="></script></div>
</div>
</body>
</html>

4个回答

︿ 3
String id = (String)session.getAttribute("newsId");取出来的id为null,检查看看是否有值
︿ 1
String id = (String)session.getAttribute("newsId");
alert(id);
--看看弹框中的id有没有值。
︿ 1
News news = newsService.getNews(Integer.parseInt(id));
java.lang.NumberFormatException: null
id为null????