JavaWeb后台从input表单获取文本值的两种方式
#### index.html
Title提交
$("#btn").click(function () {
//获取input表单文本框的值
var name=$(‘#cid‘).val();
$(window).attr(‘location‘,‘/QueryOneStudent?sid=‘+name+‘‘);
});
####index2.html
Title####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);
}
}
原文:https://www.cnblogs.com/my12/p/9581577.html