标签:生成页面 cookie row logs override 创建对象 https 响应 dog
public class cookies extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { PrintWriter writer = resp.getWriter(); writer.print("hello!"); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { doGet(req, resp); } }
自己写的类中:
需要在web.xml里面添加映射,将url映射到写好的servlet类
hello是自己取的名称,/hello是访问时用的url,com.kuang.servlet是对应的类
Tomcat的配置:类似的文章很多,要对打包的war进行一个配置
上为请求转发,下为重定向。
请求转发的httpcode任然是200,而不是代表着重定向的3xx
ServletContext servletContext = this.getServletContext(); servletContext.setAttribute("name","hahaha");
标签:生成页面 cookie row logs override 创建对象 https 响应 dog
原文地址:https://www.cnblogs.com/take-it-easy/p/12639122.html