使用HTML中From中的action调用Servlet无效
HTML页面源码<html><head><metacharset="UTF-8"><title>Form</title></head><body><formaction=...
HTML页面源码
<html>
<head>
<meta charset="UTF-8">
<title>Form</title>
</head>
<body>
<form action="/day06/RequestDemo4" method="post">
用户名:
<input type="text" name="username"><br />
<input type="submit" value="提交"><br />
</form>
</body>
</html>
Servlet程序源码如下
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/RequestDemo4")
public class RequestDemo4 extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
System.out.println(request.getParameter("username"));
}
}
单独运行时可以,但是用浏览器打开HTML点提交之后调用不了Servlet。
请问这是问什么呢?该如何调用?
运行环境是TOMCAT8,JDK8,Eclipse Luna
打错字了。。。是请问这是为什么?该如何调用? 展开
<html>
<head>
<meta charset="UTF-8">
<title>Form</title>
</head>
<body>
<form action="/day06/RequestDemo4" method="post">
用户名:
<input type="text" name="username"><br />
<input type="submit" value="提交"><br />
</form>
</body>
</html>
Servlet程序源码如下
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/RequestDemo4")
public class RequestDemo4 extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
System.out.println(request.getParameter("username"));
}
}
单独运行时可以,但是用浏览器打开HTML点提交之后调用不了Servlet。
请问这是问什么呢?该如何调用?
运行环境是TOMCAT8,JDK8,Eclipse Luna
打错字了。。。是请问这是为什么?该如何调用? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询