点击提交后出现java.lang.NumberFormatException: null异常,求大神回帖~

v1260012123 v1260012123 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
异常:
java.lang.NumberFormatException: null
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
com.action.OrderDetailServlet.service(OrderDetailServlet.java:39)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.util.EncodingFilter.doFilter(EncodingFilter.java:30)
com.util.EncodingFilter.doFilter(EncodingFilter.java:30)
OrderDetailServlet.java的代码:
public class OrderDetailServlet extends HttpServlet {
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

response.setContentType("text/html");
PrintWriter out = response.getWriter();

String orderId = request.getParameter("orderId");
String meauId = request.getParameter("meauId");
String num = request.getParameter("num");
String remark = request.getParameter("remark");

OrderDao dao = new OrderDaoImpl();

OrderDetail od = new OrderDetail();

od.setMenuId(Integer.parseInt(meauId));
od.setOrderId(Integer.parseInt(orderId));
od.setNum(Integer.parseInt(num));
od.setRemark(remark);

dao.saveOrderDetail(od);

out.print(remark);

out.flush();
out.close();
}
}

页面orderdish.jsp代码:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<%@page import="com.action.*"%>
<%
String path = request.getContextPath();
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
<meta http-equiv="description" content="This is my page" />

<title>菜品选择</title>
<style type="text/css">
body{
background-image:url(<%=path %>/img/banner.png);
display:block;
}
.tablebox{background-image:url(<%=path %>/img/bg_tm.png);font-size:15px;color:#304031}
.Add{text-align:right;margin-top:15px;margin-right:45px;}
.title{font-size:18px}
div{font-weight:bold}


</style>

<script type='text/javascript' src='<%=path %>/dwr/interface/loginService.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script language="javascript">
var i=0;
function caipuAll()
{
if(i==0)
{
document.getElementById("indicator").style.display="block";
loginService.caipuAll(callback);
i=1;
}

}
function callback(data)
{
document.getElementById("indicator").style.display="none";
DWRUtil.addOptions("meauId",data,"id","name");
}

function check()
{
if(document.formAdd.meauId.value==0)
{
alert("请选择类别");
return false;
}
return true;
}
</script>
</head>

<body>
<jsp:include page="/admin/daohang.jsp" flush="true"/>

<div class="tablebox">
<form action="<%=path %>/diancai" name="formAdd" method="post">

<table width="60%" align="center" border="0" cellpadding="0" cellspacing="0" style="margin:0 auto">
<tr height="40px">
<td colspan="7" align="center" class="title" ><span>   菜品选择</span></td>
</tr>
<tr align='center' height="30">


<td width="10%" align="right">
菜谱列表:
</td>
<td width="15%" align="left">
<table border="0">
<tr>
<td>
  
<select name="meauId" id="meauId" onclick="caipuAll()">
<option value="0">请选择菜品</option>
</select>
</td>
<td>
<img id="indicator" src="<%=path %>/img/loading.gif" style="display:none"/>
</td>
</tr>
</table>
</td>
<td width="8%"align="right">
数量:
</td>
<td width="15%" align="left">
  
<input type="text" name="num" size="20"/>
</td>
<td width="7%" align="right">
备注:
</td>
<td width="10%" align="left">
  
<input type="text" name="remark" size="20"/>
</td>
<td width="10%" align="left">
     
<input type="submit" value="提交" onclick="return check()"/>       
</tr>
</table>
</form>
</div>
</body>
</html>





...全文

相关推荐

评论 18
收藏 已收藏
分享
返回顶部
v1260012123
Web 开发 81,108 成员 341,721 内容