编写学生增删改查系统时碰到的问题

<%@ page language="java" import="java.util.*,bean.*" pageEncoding="utf-8"%>
<%
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>My JSP 'edit.jsp' starting page</title>
    
    <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">

  </head>
  
  <body>
      <h1 align="center">编辑界面</h1>
      <form action="/MVC01/ctrl?action=editConfirm" method="post"> 
    <table border="1" width="600px" align="center">
    <tr>
    <th>学号</th>
    <th>姓名</th>
    <th>性别</th>
    <th>班级</th>
    </tr>
    <tr>
    <%
        Student stu = (Student)request.getAttribute("stu");
     %>
    <td><input type="text" value=<%=stu.getId() %> id="id" /></td>
    <td><input type="text"  value=<%=stu.getStuName() %> name="name" id="name" /></td>
    <td><input type="text" value=<%=stu.getSex() %>  name="sex" id="sex" /></td>
    <td><input type="text" value=<%=stu.getClassName() %> name="className" id="className" /></td>
    </tr>
    </table>
    <div align="center"><input type="button" value="确定编辑" onclick="deal()"/></div>
    </form>
   <script type="text/javascript">
       function deal(){
           window.alert("ok");
           var _id = $("id").value;
           window.alert($("name").value);
           window.alert($("sex").value);
           window.alert($("className").value); 
           <%
               /* Student _stu = new Student();
               _stu.setId(stu.getId()); */
               System.out.println("这是在js中输出**********************************");
               System.out.println(stu.getId());
               System.out.println(stu.getStuName());
               System.out.println(stu.getSex());
               System.out.println(stu.getClassName());
           %>
       }
       
       function $(id){
           return document.getElementById(id);
       }
   </script>
  </body>
</html>

编辑页面的学生信息改变之后,进行提交,在本页面和controller中均无法获得改变后的信息,还是原来的信息。

原文地址:https://www.cnblogs.com/liaoxiaolao/p/9875752.html