修改部门功能空指针异常
Caused by: java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:542)
at java.lang.Integer.parseInt(Integer.java:615)
at com.imooc.sm.controller.DepartmentController.toEdit(DepartmentController.java:46)
public void toEdit(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Integer id=Integer.parseInt(request.getParameter("id"));
Department department=departmentService.get(id);
request.setAttribute("OBJ",department);
request.getRequestDispatcher("../department_edit.jsp").forward(request,response);
}
public void edit(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Integer id=Integer.parseInt(request.getParameter("id"));
String name=request.getParameter("name");
String address=request.getParameter("address");
Department department=new Department();
department.setId(id);
department.setName(name);
department.setAddress(address);
departmentService.edit(department);
response.sendRedirect("list.do");
}<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=8" >
<title>编辑部门</title>
<link rel="stylesheet" type="text/css" href="../css/reset.css"/>
<link rel="stylesheet" type="text/css" href="../css/common.css"/>
<link rel="stylesheet" type="text/css" href="../css/thems.css">
<script type="text/javascript" src="../js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(function(){
//自适应屏幕宽度
window.onresize=function(){ location=location };
var main_h = $(window).height();
$('.hy_list').css('height',main_h-45+'px');
var main_w = $(window).width();
$('.xjhy').css('width',main_w-40+'px');
});
</script>
</head>
<body onLoad="Resize();">
<div id="right_ctn">
<div class="right_m">
<div class="hy_list">
<div class="box_t">
<span class="name">编辑部门</span>
</div>
<div class="space_hx"> </div>
<form action="edit.do" method="post" name="addForm">
<input class="chang" type="hidden" value="${OBJ.id}">
<div class="xjhy">
<!--高级配置-->
<ul class="hypz gjpz clearfix">
<li class="clearfix">
<span class="title">名称:</span>
<div class="li_r">
<input class="chang" name="name" type="text" value="${OBJ.name}">
<i>*</i>
</div>
</li>
<li class="clearfix">
<span class="title">地址:</span>
<div class="li_r">
<input class="chang" name="address" type="text" value="${OBJ.address}">
</div>
</li>
<li class="tj_btn">
<a href="javascript:history.go(-1);" class="back">返回</a>
<a href="javascript:addForm.submit();">保存</a>
</li>
</ul>
</div>
</form>
</div>
</div>
</div>
</body>
</html><%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>部门列表</title>
<link rel="stylesheet" type="text/css" href="../css/reset.css"/>
<link rel="stylesheet" type="text/css" href="../css/common.css"/>
<link rel="stylesheet" type="text/css" href="../css/thems.css">
<script type="text/javascript" src="../js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(function(){
//自适应屏幕宽度
window.onresize=function(){ location=location };
var main_h = $(window).height();
$('.hy_list').css('height',main_h-45+'px');
var search_w = $(window).width()-40;
$('.search').css('width',search_w+'px');
//$('.list_hy').css('width',search_w+'px');
});
</script>
<!--框架高度设置-->
</head>
<body onLoad="Resize();">
<div id="right_ctn">
<div class="right_m">
<div class="hy_list">
<div class="box_t">
<span class="name">部门列表</span>
</div>
<div class="space_hx"> </div>
<!--列表-->
<table cellpadding="0" cellspacing="0" class="list_hy">
<tr>
<th scope="col">名称</th>
<th scope="col">地址</th>
<th scope="col">操作</th>
</tr>
<c:forEach items="${LIST}" var="dep">
<tr>
<td>${dep.name}</td>
<td>${dep.address}</td>
<td>
<a href="toEdit.do?${dep.id}" class="btn">编辑</a>
<a href="remove.do?${dep.id}" class="btn">删除</a>
</td>
</tr>
</c:forEach>
</table>
<!--列表-->
<!--右边底部-->
<div class="r_foot">
<div class="r_foot_m">
<a href="toAdd.do" class="btn">添加</a>
</div>
</div>
<!--右边底部-->
</div>
<!--会议列表-->
</div>
</div>
</body>
</html>14
收起
正在回答 回答被采纳积分+1
2回答
4. SSM到Spring Boot入门与综合实战
- 参与学习 人
- 提交作业 323 份
- 解答问题 8263 个
本阶段将带你学习主流框架SSM,以及SpringBoot ,打通成为Java工程师的最后一公里!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星