IDEA开发Servlet跳转后页面空白,求解!~~

u010817365 2016-07-31 05:49:08
Tomcat7和8都试过,一样的结果。请问是哪里写错了。
index.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>title</title>
</head>
<body>
<a href="ServletFirst">servlet</a>
</body>
</html>

ServletFirst:
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class ServletFirst extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("success");
PrintWriter ou = response.getWriter();
ou.print("222");
}

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
}


下面是web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<servlet>
<servlet-name>ServletFirst</servlet-name>
<servlet-class>ServletFirst</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletFirst</servlet-name>
<url-pattern>/ServletFirst</url-pattern>
</servlet-mapping>
</web-app>


...全文
491 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
grave2015 2017-03-13
  • 打赏
  • 举报
回复
我也不会,现在解决了吗
u010817365 2016-07-31
  • 打赏
  • 举报
回复
求版主删帖、、、

81,095

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧