为了账号安全,请及时绑定邮箱和手机立即绑定

新手学JAVA WEB问题

新手学JAVA WEB问题

UYOU 2019-03-29 23:15:57
public class AllServlet extends HttpServlet {    String title = "title...";    private static final long serialVersionUID = 1L;    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {        request.getRequestDispatcher("/themes/tuzuan/all.jsp").forward(request, response);    }    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {    }}这个 title 在 all.jsp 怎么获取显示到网页上
查看完整描述

1 回答

?
一只斗牛犬

TA贡献1784条经验 获得超2个赞

需要在request中设置相应的属性才能在页面接收到


public class AllServlet extends HttpServlet {


    String title = "title...";


    private static final long serialVersionUID = 1L;


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setAttribute("title", title);

        request.getRequestDispatcher("/themes/tuzuan/all.jsp").forward(request, response);

    }


    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {




    }


}


查看完整回答
反对 回复 2019-04-15
  • 1 回答
  • 0 关注
  • 340 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信