1. 程式人生 > >struts2接收javabean物件時注意事項

struts2接收javabean物件時注意事項

struts2在接收javabean物件的時候,action的中的屬性既要有get方法也要有set方法,不然只能接收到一個屬性。

示例如下:

                    xtype: 'form', 
                    itemId : 'form1',  
                    region: 'center',
    				trackResetOnLoad:true,
                    defaults: {
                        labelWidth: 80
                    },
                    bodyPadding: '20 10 10 10', 
                    items: [
                        {  xtype: 'textfield',
                            anchor: '100%',
                            fieldLabel: '預警型別',
                            name : 'warningSMSVo.warningType', 
                            allowBlank: false,
                            blankText :'預警型別不能為空'
                        } ,
                        {
                            xtype: 'combo',
                            anchor: '100%',
                            fieldLabel: '傳送標誌',
                            queryMode: 'local',
                            displayField: 'name',
                            valueField: 'code',
                            editable:false,
                            store:Ext.create('Ext.data.Store', {
                                	fields: ['code', 'name'],
		                            data : [
		                                {"code":"1", "name":"啟用"},
		                                {"code":"0", "name":"不啟用"}  
		                            ]
		                        }),
                            name : 'warningSMSVo.isSend'
                        } ,
                        {
                            xtype: 'textarea',
                            anchor: '100%',
                            fieldLabel: '接收人',
                            height: 60,
                            name : 'warningSMSVo.users', 
							allowBlank: false,
							blankText :'接收人不能為空'
                        } ,
                        {
                            xtype: 'textarea',
                            anchor: '100%',
                            fieldLabel: '手機號碼',
                            height: 60,
                            name : 'warningSMSVo.phoneNumbers', 
                            allowBlank: false,
                            blankText :'手機號碼不能為空'
                        } 
                    ]
                
	private WarningSMSVo warningSMSVo;
	public void setWarningSMSVo(WarningSMSVo warningSMSVo) {
		this.warningSMSVo = warningSMSVo;
	}

	public WarningSMSVo getWarningSMSVo() {
		return warningSMSVo;
	}