• JavaWeb后台从input表单获取文本值的两种方式


     JavaWeb后台从input表单获取文本值的两种方式
    ####   index.html
        <!DOCTYPE html>
        <html lang="en">
        <head>
            <meta charset="UTF-8">
            <title>Title</title>
        </head>
        <body>
        
        <input type="text"  id="cid"/>
        <button id="btn">提交</button>
        <script src="admin/js/jquery.min.js"></script>
        <script>
        
           $("#btn").click(function () {
                //获取input表单文本框的值
               var name=$('#cid').val();
                $(window).attr('location','/QueryOneStudent?name='+name+'');
            });
        </script>
        </body>
        </html>
    
    ####index2.html
        <!DOCTYPE html>
        <html lang="en">
        <head>
            <meta charset="UTF-8">
            <title>Title</title>
        </head>
        <body>
        <form action="/QueryOneStudent">
            <input type="text" name="name"/>
            <input type="submit" value="提交"/>
        </form>
        </body>
        </html>
    
    ####QueryOneStudent.java文件
        @WebServlet("/QueryOneStudent")
        public class QueryOneStudent extends HttpServlet {
        @Override
        protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            System.out.println("QueryOneStudent");
         //获取参数
            String name = req.getParameter("name");
            System.out.println(name);
    
        }
        }
     
    
     
      
    
      
    
     
     
    

      

  • 相关阅读:
    magento 去掉index.php
    TCP三次握手与四次挥手
    <Jper和Iperf>的安装及使用
    【Python】安装方法小结
    【ubuntu】日常网络配置信息的查看及修改
    DNS解析
    【Dig工具】
    【ping/tracert】的简单使用
    【VMvare】yum在线源
    配置文件加载
  • 原文地址:https://www.cnblogs.com/my12/p/9581577.html
Copyright © 2020-2023  润新知