有一页面,内容有
<input type="text" name="productName">
<input type="text" name="price">
<input type="file" >怎么上传??
图片上传的路径要添加到数据库里?
大家给点思路或解决方法?
<input type="text" name="productName">
<input type="text" name="price">
<input type="file" >怎么上传??
图片上传的路径要添加到数据库里?
大家给点思路或解决方法?
解决方案 »
- 我就会写简单的java代码,据说要在思想上有改观才能成为牛人,怎样做
- axis1.4的错误:类不能继承接口IncompatibleClassChangeError
- 制作相册遇到的问题 急急急!!!!!
- 怎么把jsp页面列表框text值传到servlet
- 一个关于Bean的小问题
- 我装了Tomcat4.1.24和Apache2.0.48,现在我想装一个IIS,怎么配置?
- 各位大哥帮忙看看,我的tomcat总是死,是不是我的数据炉连接没有关号呀
- 有没有高手可以帮助小弟解决如下问题?谢先!!!
- struts的例子中的验证问题。
- 请问如何用jsp开发管理信息系统
- 什么情况会出现The requested resource is not available...
- hibernate3里没有hbm2java的工具了吗
如果要传文件,推荐使用apache
if(!isMultipart){
//普通的form
}
else
{
//附件
}
在servelt这样写,前提是你使用apache.commons
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if(!isMultipart){
//普通的form
}
else
{
if (item.isFormField()) {}
}
其他页面数据可以用javascript 代码获得form里面的值。前提是你的name都不一样。
而且可以实现无刷新文件上传。只是貌似ajax。ajax实现不了文件上传但是可以模拟。。
<input type="text" name="productName">
<input type="text" name="price">
<input type="file" name="image">
</form>
servlet里用ServletInputStream sis = request.getInputStream();获取二进制流
<input type= "text " name= "productName " >
<input type= "text " name= "price " >
<input type= "file " > 除了这个<input type= "file " > ,还想在request里面得到(<input type= "text " name= "productName " ><input type= "text " name= "price " >)productName 和 price 的值?
如果是,smartupload网上找例子看下
如果用的是commons-fileupload.jar,我也在视图解决怎么获得productName 和price 值的问题
这里有个例子你可以参考下:http://www.java3z.com/cwbwebhome/article/article1a/168.html?id=359
然后在Action里边获取其值