您好,我无法从我的index.jsp 文件中的a 中获取任何值。我正在使用 tomcat7,运行 index.jsp 并单击发送按钮后没有任何反应。 System.out.prinln() 不打印任何内容或 null ;(
index.jsp
%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title></title>
</head>
<body>
<form acton="addnewtask.jsp" method="post" >
<label for="name">Name</label>
<input type="text" class="form-control" id="name" placeholder="Name">
<button type="submit" class="btn btn-danger">Add</button>
</body>
</html>
addnewtask.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
String s = request.getParameter("name");
System.out.println(s);
%>
你知道我做错了什么吗?
最佳答案
此行允许您获取带有名称而不是id的参数:
String s = request.getParameter("name");
在您的输入中添加名称并更正表单属性操作的拼写错误:
<form action="addnewtask.jsp" method="post" >
<label for="name">Name</label>
<input name="name" type="text" class="form-control" id="name" placeholder="Name">
<button type="submit" class="btn btn-danger">Add</button>
<form>
关于java - 为什么request.getParamether在jsp中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56440352/