我是Spring的新手,请任何人解决我的问题....
我的employee.jsp 页面是....
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>${message}</title>
</head>
<body>
<h3>${message}</ h3>
<br/>
<table>
<tr>
<th> Employee Code </ th>
<th> Name </ th>
<th> Designation </ th>
<th> Date of Joining </ th>
</tr>
<c:forEach items="${employee}" var="employe">
<tr>
<td> <c:out value="${employe.employeeCode}"> </c:out> </td>
<td><a href="updateEmployee.htm"> <c:out value="${employe.fullName}"> </c:out> </a></td>
<td> <c:out value="${employe.designation}"> </c:out> </td>
</tr>
</c:forEach>
</table>
</body>
</html>
对应的控制器代码是......
public class EmployeeController implements Controller {
Session ses=null;
@Override
public ModelAndView handleRequest (HttpServletRequest hsr,
HttpServletResponse hsr1) throws Exception {
ModelAndView mv = new ModelAndView ("employee");
String out = "List of Employees";
try {
Session session = HibernateUtil.getSessionFactory (). getCurrentSession ();
session.beginTransaction ();
List result = session.createQuery ("from Employee").list();
mv.addObject ("employee", result);
session.getTransaction (). commit ();
} catch (Exception e) {
e.printStackTrace ();
}
mv.addObject ("message", out);
return mv;
}
}
UpdateEmployee.jsp 代码是....
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>New Contact </title>
<!--<link rel="stylesheet" href="ui.all.css" type="text/css" media="screen" />
<script type="text/javascript" src="js1.js"></script>
<script type="text/javascript" src="js2.js"></script>-->
</head>
<body>
<h4><a href="index.htm">home</a> </h4>
<h3>New Contact</h3>
<spring:nestedPath path="updateEmployee">
<form action="" method="post">
Name
<spring:bind path="employeeCode">
<input type="text" name="${status.expression}" value="${status.value}">
</spring:bind>
<FONT color="red"><form:errors
path="name" /></FONT>
Address
<spring:bind path="FullName">
<input type="text" name="${status.expression}" value="${status.value}">
</spring:bind>
Email
<spring:bind path="Designation">
<input type="text" name="${status.expression}" value="${status.value}">
</spring:bind>
<input type="submit" value="Register">
<font color="red"><form:errors
path="name" /></font>
</form>
</spring:nestedPath>
</body>
帮助我使用 updatecontroller 的控制器代码,根据员工表中的 href 自动填充 updateEmployee.jsp 页面上的字段。