获取初始化参数

在web中插入这个文件
获取完然后拿取文件
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
ServletContext context=this.getServletContext();
String url=context.getInitParameter("url");
resp.getWriter().print(url);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doGet(req,resp);
}
请求转发
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("输出一句话进去01");
ServletContext context=this.getServletContext();
//RequestDispatcher requestDispatcher =context.getRequestDispatcher("/nf");
//requestDispatcher.forward(req,resp);
context.getRequestDispatcher("/fn").forward(req,resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doGet(req,resp);//调用forword实现请求转发
}
浙公网安备 33010602011771号