1. 程式人生 > >jsp頁面獲取struts2後臺的值

jsp頁面獲取struts2後臺的值

業務需求:頁面載入時設定“需求發起”查詢文字框地為當前使用者所屬區部。

jsp頁面程式碼:

<input class="easyui-textbox"  value = "${defaultCode}">

jsp頁面利用${}獲取後臺的defaultCode變數的值。後臺只需要在載入頁面時取得該值並定義get方法。

    private String defaultCode;

	@Action(value = "index", results = { @Result(name = "success",type = "dispatcher", location = "../../../../line/subline_list.jsp") })
	public String index() {
		defaultCode = getCurrentDefaultZoneCode();
		Department department = departmentService.getDepartment(defaultCode);
		if(department!=null){
			defaultCode = department.getAreaCode();
		}
		return SUCCESS; 
	}

	public String getDefaultCode() {
		return defaultCode;
	}