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


    <%@ 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中均无法获得改变后的信息,还是原来的信息。

  • 相关阅读:
    迭代器实现斐波那契数列
    type 创建类,赋予类静态方法等
    使用types库修改函数
    使用property取代getter和setter方法
    pdb 进行调试
    nonlocal 访问变量
    timeit_list操作测试
    metaclass 拦截类的创建,并返回
    isinstance方法判断可迭代和迭代器
    苹果cms10 官方QQ微信防红防封代码
  • 原文地址:https://www.cnblogs.com/liaoxiaolao/p/9875752.html
Copyright © 2020-2023  润新知