Java 为什么servlet中的请求参数为null?
从我的表单中,我已经将一个特定的数据库列放入jsp表单中的输入框中,这是成功的,但是问题是,我也希望使用请求参数将其放入后端,但结果是得到null jsp表单代码:Java 为什么servlet中的请求参数为null?,java,jsp,Java,Jsp,从我的表单中,我已经将一个特定的数据库列放入jsp表单中的输入框中,这是成功的,但是问题是,我也希望使用请求参数将其放入后端,但结果是得到null jsp表单代码: <form style="height: 100% ; width: 100% ; margin-top: 5% ; margin-right: 0%" method="GET"> &
<form style="height: 100% ; width: 100% ; margin-top: 5% ; margin-right: 0%" method="GET">
<table class="styled-table" style="margin-bottom: 15px; margin-top:0%; height: 80%">
<thead>
<tr>
<th>Doctor Name</th>
<th>Speciality</th>
<th>Channel</th>
</tr>
</thead>
<tbody>
<%
String input = request.getParameter("input");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/hms", "root", "");
Statement st = con.createStatement();
ResultSet rs = null;
String strQuery;
if (input != null) {
strQuery = " SELECT * FROM staff WHERE Staff_Name like '%" + input + "%' or Staff_speciality like '%" + input + "%' AND Position= 'Doctor' ";
} else {
strQuery = "SELECT * FROM staff WHERE Position= 'Doctor' ";
}
rs = st.executeQuery(strQuery);
if (rs != null) {
while (rs.next()) {
%>
<tr class="row">
<td><%=rs.getString("Staff_Name")%><input name="docname" type="text" value="<%=rs.getString("Staff_Name")%>"></td>
<td><%=rs.getString("Staff_speciality")%></td>
<td><a title="Channel Now " style=" display: flex; justify-content:center; align-items: center; color:#39447a;" href="<%=request.getContextPath()%>/ChannelDoc/channel"><i style="margin-left: 4%;" class="fa fa-address-card-o"></i></a></td>
</tr>
<% }
}
%>
</tbody>
</table >
</form>
servlet为我提供空值,因此我无法继续进行其他后端工作,如果能在servlet中获得docname值,我们将不胜感激
提前感谢您。如何将
输入发送到servlet?发送到servlet的代码是:请不要对此使用注释。请回答您的问题。一般来说,请提供一个。注意,谢谢@FedericoklezCulloca
<a title="Channel Now " style=" display: flex; justify-content:center; align-items: center; color:#39447a;" href="<%=request.getContextPath()%>/ChannelDoc/channel">
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (request.getServletPath().contains("/channel")) {
String name=request.getParameter("docname");
System.out.print(name);
}