luofuxiang
直接将要跳转的servlet的url-pattern作为跳转链接就行,假设我有一个servlet如下所示(注意url-pattern):import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/CourseInfoManage") //注意这里,/CourseInfoManage为servlet的url-pattern
public class CourseInfoManage extends HttpServlet {
public CourseInfoManage() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
......
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
......
}
}在jsp页面的超链接中:<a href="CourseInfoManage">课程信息管理</a>java代码中:response.sendRedirect("CourseInfoManage");当然,有时候可能你的jsp页面和servlet不在同一目录下,可能需要用绝对路径。