怪兽_Monster
2017-08-20 14:16
package com.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.sun.mail.iap.Response;
public class HelloServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("处理GET请求...");
PrintWriter out = response.getWriter();
response.setContentType("text/html;charset=utf-8");
out.println("<strong>Hello Servlet</strong>");
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("处理POST请求...");
PrintWriter out = response.getWriter();
response.setContentType("text/html;charset=utf-8");
out.println("<strong>Hello Servlet</strong>");
}
}
我点击那个 a标签的连接 就直接弹出来下载文件
删掉重写response.setContentType("text/html;charset=utf-8");
我之前也是提示下载,重写就好了。
谢谢大家了
麻烦大家有空看下我的代码 ,救救小白
JAVA遇见HTML——Servlet篇
160613 学习 · 1029 问题
相似问题