Struts2 action前的資料預處理

weixin_30788239發表於2020-04-05
Struts2 action前的資料預處理

在進入updateDormitory.jsp頁面,之前,獲取了dormitory和buildings的訊息,放入值棧。頁面就可以獲取得到了。

<td align="center"><a href="beforeUpdateDormitory?Dormitory_ID=${Dormitory_ID}">修改</a> 

<action name="beforeUpdateDormitory" class="com.wolf.dormitoryManage.action.AdminAction" method="beforeUpdateDormitory">
            <result>/jsp/updateDormitory.jsp</result>
        </action> 

public String beforeUpdateDormitory() {
        DormitoryDao dao = new DormitoryDaoImpl();
        int dormitoryID = new Integer(ServletActionContext.getRequest().getParameter("Dormitory_ID"));
        dormitory = dao.getByDormitoryID(dormitoryID);
        BuildingDao dao2 = new BuildingDaoImpl();
        buildings = dao2.list();
        return SUCCESS;
    }  




轉載於:https://www.cnblogs.com/homer3000/p/4470759.html

相關文章