我使用的是hibernate+struts2+spring,我想通过struts2的<s:file></s:file>的这个标签做文件上传,当我在services中获取uservo.tpictures这个的时候,就出错了,请各位大侠帮忙看看!!错误信息:
ognl.NoSuchPropertyException: com.vo.UserVO.tpicturesContentType
at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:166)
at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:28)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2225)
at ognl.ASTProperty.setValueBody(ASTProperty.java:127)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
at ognl.SimpleNode.setValue(SimpleNode.java:301)
at ognl.ASTChain.setValueBody(ASTChain.java:227)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
at ognl.SimpleNode.setValue(SimpleNode.java:301)
at ognl.Ognl.setValue(Ognl.java:737)2010-08-17 16:26:03  Error setting expression 'uservo.tpicturesFileName' with value '[Ljava.lang.String;@13f212a'
ognl.NoSuchPropertyException: com.vo.UserVO.tpicturesFileName
at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:166)
at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:28)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2225)
at ognl.ASTProperty.setValueBody(ASTProperty.java:127)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
at ognl.SimpleNode.setValue(SimpleNode.java:301)
at ognl.ASTChain.setValueBody(ASTChain.java:227)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
at ognl.SimpleNode.setValue(SimpleNode.java:301)
at ognl.Ognl.setValue(Ognl.java:737)页面代码:<s:form method="post" action="user!save.action" enctype="multipart/form-data">
<table align="center" border="1px" width="60%">
<tr>
<td>
<s:textfield label="用户名" name="uservo.tname"></s:textfield>
</td>
</tr>
<tr>
<td>
<s:file label="玉照" name="uservo.tpictures"></s:file>
</td>
</tr>
          </table>
</s:form>

UserVO代码:

         private Integer tid;
private String tname;
private Integer tsex;
private Integer tage;
private String tplace;
private String temail;
private String tphone;
private File tpictures;
private List tlovees;
private String tpwd;
UserPOJO代码:
         private Integer tid;
private Dept dept;
private String tname;
private Integer tsex;
private Integer tage;
private String tplace;
private String temail;
private String tphone;
private String tpicture;
private String tloves;
private String tpwd;

解决方案 »

  1.   

    这个'uservo.tpicturesFileName' 是什么?
      

  2.   

    private File tpictures;struts2的文件上传,除了要定义界面元素这个File域及get/set方法之外,还必须提供另外两个相关域的定义:
    File的变量名+ContentType和File的变量名+FileName;
    在你这里,就是要求你的UserVO这个类里面,再加上:
    private String tpicturesContentType; //存文件MIME类型
    private String tpicturesFileName; //存文件名
    并提供他们的get/set方法。
    这个在struts2的示例里面说得很清楚了。
      

  3.   

    'uservo.tpicturesFileName'  这是什么? 是不是你在服务器端写错了?
      

  4.   

    'uservo.tpicturesFileName' 这个我也不知道哪来的!
      

  5.   

    get/set方法都写了
    还是出现那个错误!