0
我想從servlet發送一個參數到一個jsp文件。這是servlet:發送從servlet到jsp的響應
public class HomepageController extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
CategoryService cs = new CategoryService();
request.setAttribute("attribute", "Hello world!");
request.getRequestDispatcher("/views/homepage.jsp").forward(request,response);
}
}
而在jsp中,我試圖像這樣訪問它$ {attribute}但它不起作用。 它顯示爲沒有定義。
正所謂HomepageController? –
是的,它被稱爲 – Jones
檢查錯別字 –