我使用的是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;
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;
解决方案 »
- 为什么连接数据库驱动会报错
- 国际化问题
- servlet 图形验证码的问题,要求点击刷新
- struts中的ActionFrom的过滤
- 请问 org.glassfish.web.loader.WebappClassLoader.loadClass 是到哪个地方加载类啊?
- 编写一个函数sum来计算前n个自然数的和,n是传入的正整数参数。
- jsp servlet bean 编写好后运行出现这种错误,请大家帮帮忙~~
- 消息队列rabbitmq可以实现这个功能吗
- 小弟刚开始学jsp,我装的是JBuilder8.0,请问jsp环境还得怎么配置呀?
- Tomcat和Weblogic的比较?!
- jsp引入action
- 帮忙写一下正则表达式
File的变量名+ContentType和File的变量名+FileName;
在你这里,就是要求你的UserVO这个类里面,再加上:
private String tpicturesContentType; //存文件MIME类型
private String tpicturesFileName; //存文件名
并提供他们的get/set方法。
这个在struts2的示例里面说得很清楚了。
还是出现那个错误!