刚学到servlet编程,编了个jsp如下,
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="<%=request.getContextPath()%>/AcceptForm" method="post" >
姓名:<input type="text" name="name"><br />
省份: <input type="text" name="province"><br />
<input type="submit" value="提交">
</form>
</body>
</html>
servlet如下:
AcceptForm.java
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
response.setCharacterEncoding("UTF-8");
String name = request.getParameter("name");
String province = request.getParameter("province");
out.println(name+province);
out.println(", using the GET method");
}
web.xml配置如下:
在Tomcat7执行的结果却是这样
应该访问的是:
求解啊求救啊 大神教我怎么破
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="<%=request.getContextPath()%>/AcceptForm" method="post" >
姓名:<input type="text" name="name"><br />
省份: <input type="text" name="province"><br />
<input type="submit" value="提交">
</form>
</body>
</html>
servlet如下:
AcceptForm.java
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
response.setCharacterEncoding("UTF-8");
String name = request.getParameter("name");
String province = request.getParameter("province");
out.println(name+province);
out.println(", using the GET method");
}
web.xml配置如下:
在Tomcat7执行的结果却是这样
应该访问的是:
求解啊求救啊 大神教我怎么破