错误找不到,请各位大神帮忙找一下错,具体的修改

YangHaoBB 终极瓜皮软件实习生  2017-06-27 03:36:19
错误提示
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"> 
<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"> <%=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&at=231&aurl=&cad=1&ccd=24&cec=UTF-8&cfv=18&ch=0&col=zh-CN&conBW=0&conOP=1&cpa=1&dai=7&dis=0&ltr=http%3A%2F%2Fwww.nruan.com%2Fwin-key.html&ltu=http%3A%2F%2Fwww.nruan.com%2F&lu_161=0&lunum=6&n=68029130_cpr&pcs=1347x643&pis=10000x10000&ps=3110x1028&psr=1366x768&pss=1347x5630&qn=0da09fb18e2d768a&rad=&rsi0=300&rsi1=250&rsi5=4&rss0=%23FFFFFF&rss1=%23FFFFFF&rss2=%230000ff&rss3=%23444444&rss4=%23008000&rss5=&rss6=%23e10900&rss7=&scale=&skin=tabcloud_skin_3&stid=5&td_id=2112317&titFF=%E5%AE%8B%E4%BD%93&titFS=12&titTA=left&tn=text_default_300_250&tpr=1436888793184&ts=1&version=2.0&xuanting=0&dtm=BAIDU_DUP2_SETJSONADSLOT&dc=2&di=u2112317&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&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&dcb=BAIDU_DUP2_define&dtm=BAIDU_DUP2_SETJSONADSLOT&dbv=2&dci=0&dri=0&dis=0&dai=7&dds=&drs=1&dvi=1432188695&ltu=http%3A%2F%2Fwww.nruan.com%2F&liu=&ltr=http%3A%2F%2Fwww.nruan.com%2Fwin-key.html&lcr=&ps=3110x1028&psr=1366x768&par=1366x728&pcs=1347x643&pss=1347x5630&pis=-1x-1&cfv=18&ccd=24&chi=4&cja=true&cpl=6&cmi=8&cce=true&col=zh-CN&cec=UTF-8&cdo=-1&tsr=57538&tlm=1436888850&tcn=1436888851&tpr=1436888793184&dpt=none&coa=&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&baidu_id="></script></div>
</div>
</body>
</html>
...全文
144 点赞 收藏 5
写回复
5 条回复
lyn584238910 2017年06月27日
建议你用debugger跑一下,这样太乱了,没法找错误,
回复 点赞
云墨浅殇 2017年06月27日
引用 3 楼 qq_15821497 的回复:
String id = (String)session.getAttribute("newsId"); alert(id); --看看弹框中的id有没有值。
回复 点赞
张元良 2017年06月27日
String id = (String)session.getAttribute("newsId"); alert(id); --看看弹框中的id有没有值。
回复 点赞
云墨浅殇 2017年06月27日
String id = (String)session.getAttribute("newsId");取出来的id为null,检查看看是否有值
回复 点赞
李德胜1995 2017年06月27日
News news = newsService.getNews(Integer.parseInt(id)); java.lang.NumberFormatException: null id为null????
回复 点赞
发动态
发帖子
Eclipse
创建于2007-09-28

3.1w+

社区成员

4.9w+

社区内容

Java Eclipse
社区公告
暂无公告