借花献佛:
:)String contentType = request.getContentType();
if(contentType != null && contentType.startsWith("multipart/form-data")){
InputStream in = request.getInputStream();
ByteArrayOutputStream buf = new ByteArrayOutputStream();
int data = -1;
int size = 0;
while((data = in.read()) > -1)
{
buf.write(data);
}
//use buf as OutputStream on your server side}
:)String contentType = request.getContentType();
if(contentType != null && contentType.startsWith("multipart/form-data")){
InputStream in = request.getInputStream();
ByteArrayOutputStream buf = new ByteArrayOutputStream();
int data = -1;
int size = 0;
while((data = in.read()) > -1)
{
buf.write(data);
}
//use buf as OutputStream on your server side}
解决方案 »
- 集成了flex4.7的myeclipse不能可视化编辑mxml文件???
- 我想做一个焦点房地产网业主论坛类似风格的论坛,请高人指点
- 请教一个sql语句转成hql的问题
- 请教把servlet放在一个包里面,应该如何在web.xml中注册??
- 求html中img标签src属性引进的图片(非背景) 怎么样 才能适应不同的分辨率
- 那位朋友有维新的JAVA视频培训课程,我用张孝祥老师的全套视频和您换着看
- Shanghai---------------Senior J2EE Arch Engineer----------------------Salary 10000RMB+
- jsp语句中不能嵌套循环吗
- 有谁知道下面报的是什么错吗?希望大家讲错在什么地方?
- 急急急,手边没编程工具,求帮计算字符串,求signature=?
- 求助,表单上多文件上传
- 求一篇关于用户注册、登陆的文章代码?
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload"/> txttitle=mySmartUpload.getRequest().getParameter("texttitle").trim();
把你要传的参数放到Url里
比如:a4.jsp?par1='..'&par2='..'
这样就可以取了!
<input type=text name="texttitle">
-->
txttitle=mySmartUpload.getRequest().getParameter("texttitle").trim();
根本不可能取到的,因为encType="multipart/form-data形式,它是流的形势,根本不能通过getParameter("texttitle")取到中文值的!
txttitle=mySmartUpload.getRequest().getParameter("texttitle").trim();you must write :
mySmartUpload.upload(); before it first.
and if you read the source code ,you will know the method upload() is to parth the stream,so no matter what you want to do with SmartUpload, use it first.
我用在上型机上,com.jspsmart.upload.SmartUpload up=new com.jspsmart.upload.SmartUpload();
com.jspsmart.upload.Request qs = null;
try
{
up.setMaxFileSize(200*1024*1024); //最大上传文件2M
up.init(config);
up.service(request,response);
up.upload();
qs=up.getRequest();
}
catch(Exception e)
{
String err=Function.ToString(e.getMessage());
if(err.indexOf("Size exceeded for this file")!=-1)
{
out.println("<script>alert('文件太大了,请控制在2M以内!')</script>");
}
} 我也是像你所写的用upload()在先,根本取不到其它文本框的中文值(非中文的是可以取到的)我要实现的jsp页面就是一个回复文本框 + 可以上传一个附件的功能!
这个问题实在太烦了!
SmartUpload mySmartUpload = new SmartUpload();
mySmartUpload.initialize(config,request,response);
mySmartUpload.upload();
String fileCategory = (mySmartUpload.getRequest().getParameter("fileCategory")==null)?"":mySmartUpload.getRequest().getParameter("fileCategory").toString() ;the above code has no problem in my computer when running in weblogic 7.
And chinese character also can be got correctly.
So I think maybe there are some other questions with your code which are not involved with SmartUpload.
<%
upload.initialize(pageContext);
upload.upload();
java.util.Enumeration e = upload.getRequest().getParameterNames();
while(e.hasMoreElements()){
String fieldname = (String)e.nextElement();//取文本框或是其他控件的名称
String fieldvalue = upload.getRequest().getParameterValues(fieldname);//取对应值
}
%>
String fieldvalue = upload.getRequest().getParameterValues(fieldname);
应该是
String[] fieldvalue = upload.getRequest().getParameterValues(fieldname);
返回的是数祖类型的