Struts2 修改页面的显示
修改页面:
Student 实体类:
private Student stu;
// 转到修页面
public String toUpdate() {
stu = service.findById(stu.getId());
return "update";
}
修改页面:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>学生信息修改</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/style.css">
<script type="text/javascript" src="<%=path%>/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery.validate_pack.js"></script>
<script type="text/javascript" src="<%=path%>/js/student.js"></script>
</head>
<body style="text-align:center">
<form action="<%=request.getContextPath()%>/student_update.action" id="studentUpdateForm"
method="post">
<input type="hidden" name="stu.id" value="<s:property value='stu.id'/>"/>
<input type="hidden" name="currentPage" value="<s:property value='currentPage'/>"/>
学生信息修改
<p>
<label class="required">
姓名:
</label>
<input type="text" id="name"
value="<s:property value='stu.name'/>"
name="stu.name" />
<input type="hidden"
value="<s:property value='stu.name'/>"
id="stuname" />
<span id="namespan"></span>
</p>
<p>
<label class="required">
年龄:
</label>
<input type="text" id="chooseone"
value="<s:property value='stu.age'/>"
name="stu.age" />
<span id="agespan"></span>
</p>
<p>
<label class="required">
性别:
</label>
<input type="text" id="choosetwo" name="stu.sex" value="<s:property value='stu.sex'/>" />
<span id="sexspan"></span>
</p>
<p>
<label class="required">
地址:
</label>
<input type="text" id="choosethree" value="<s:property value='stu.address'/>"
name="stu.address" />
<span id="addressspan"></span>
</p>
<center>
<input type="submit"
id="send" value="提交" />
<input type="button" value="返回" onclick="javascript:window.location.href='<%=path%>/student_query.action?currentPage=<s:property value='currentPage'/>'"/>
</center>
</form>
</body>
</html>