Ext inputType:'file' 取值问题,急~

来源:百度知道 编辑:UC知道 时间:2024/07/05 13:42:45
使用 Ext 生成 Ext.onReady(function(){
var jsxmgk = new Ext.FormPanel({
labelWidth: 145,
中间省略....
items: [{
xtype:'fieldset',
title: '基本情况',
collapsible: true,
autoHeight:true,
defaults: {width: 210},
defaultType: 'textfield',
items :[{
xtype:'hidden',
name:'xmgkBean.XMBH'
},{
fieldLabel: '路线起讫点',
name: 'xmgkBean.LXQQD',
allowBlank:true
},
中间省略
items :[{fieldLabel: '工可研审批机构、文号',
name: 'xmgkBean.GKYSPJGWH'
},{

f

这个路径是取不到的,file类型的直接传到后台的是一个临时文件,而在客户端的路径在struts2看来是没有用的,所以struts2不会取这个值。(事实上是有点用的,有时候需要取后缀名啥的)
所以大家无奈之下通用的做法是写一个隐藏控件通过自己写的js取得,用隐藏控件传入后台。
http://www.javaeye.com/wiki/struts2/1365-passing-parameters-in-struts2
在javaeye这篇文章里在文件上传那一段也有解释,并给了一个解决办法,可以参考一下

{
xtype:'textfield',
inputType:'file',
fieldLabel: '选择文件',
name:"uploadfile",
anchor:'95%'
}

你用js。。就直接getValue()就得到了路径呀

fieldLabel:'文件路径',
//xtype:'fileuploadfield',
name:'upload',
//id:'upFile',
inputType: 'file',
allowBlank:false,
blankText:'文件路径不能为空',
id:'