0
我試圖弄清楚如何將在Action類中創建的值傳遞給模型(在我的情況下是jsp視圖)。我是Struts 2框架的新手。從動作傳遞值到Struts 2中的模型
我的情況:
- 我從請求URL的參數。
- 我使用這個值來生成我自己的類的對象 - 產品(我在執行方法中執行它)。
- 然後我想將Product類對象的列表注入到jsp視圖中。
我的問題是 - 如何在jsp視圖中插入我自己的類的對象。
我實現Action類:
public class ProductAction extends ActionSupport {
private int n;
public int getN() {
return n;
}
public void setN(int n) {
this.n = n;
}
public String execute() throws Exception {
List<Product> products = Service.getProducts(n);//I want to inject this to jsp view
return SUCCESS;
}
http://struts.apache.org/docs/tutorials.html –
問題尋求幫助調試(「爲什麼不是這個代碼的工作?」)必須包括所期望的行爲,一個具體問題或錯誤,在問題本身中重現它所需的最短代碼。沒有明確問題陳述的問題對其他讀者無益。請參閱:如何創建最小,完整和可驗證示例。 –