首先在中将servlet配置为欢迎文件
web.xml。如果
web.xml不存在,则在WEB-INF文件夹中手动创建它,并将其放在内容下面。
<welcome-file-list> <welcome-file>foo</welcome-file></welcome-file-list>
比在向jsp发出servlet的请求中,可以说您的jsp名称
index.jsp比servlet代码看起来像:
@WebServlet(name = "Placeholder",urlPatterns = {"/foo"})public class Placeholder extends HttpServlet { public static int numbers=5; public void doGet (HttpServletRequest _req, HttpServletResponse _res) throws ServletException, IOException { HttpSession session = _req.getSession(); session.setAttribute("wee","ok"); _res.sendRedirect("index.jsp"); }}现在运行您的servlet,您将看到输出。希望这能解决您的问题!!!



