haoshibai 真的好失败!!(给分了)

haoshibai 2004-09-23 09:09:17
我做用户注册.我用了一个上传头像的功能,当我上传图片跟其它的信息时图片的名字不能够存储在数据库中其他的数据可以在数据库中保存.图片的名字为NULL 在我不填其他的值就只上传图片时就可以存储在数据库中 不知道什么原因希望大家想想!!
代码如下!!
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.sql.*,yaya.opendb" %>
<%@ page import="com.jspsmart.upload.*"%>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<jsp:useBean id="cm" class="yaya.opendb" scope="page" />
<jsp:useBean id="binguanjiudian" class="yaya.binguanjiudian" scope="page" />

<%!
public String codeString(String s)
{String str=s;
try{
byte a[]=str.getBytes("iso-8859-1");
str=new String(a);
return str;
}
catch(Exception e)
{return str;
}
}
%>
<%
String name=request.getParameter("name");
if(name==null)
{
name="";
}
name=codeString(name);

String jianjie=request.getParameter("jianjie");
if(jianjie==null)
{
jianjie="";
}
jianjie=codeString(jianjie);

String address=request.getParameter("address");
if(address==null)
{
address="";
}
address=codeString(address);

String phone=request.getParameter("phone");
if(phone==null)
{
phone="";
}
phone=codeString(phone);

String juti=request.getParameter("juti");
if(juti==null)
{
juti="";
}
juti=codeString(juti);



String wangming=request.getParameter("wangming");
if(wangming==null)
{
wangming="";
}
wangming=codeString(wangming);

String jichang=request.getParameter("jichang");
if(jichang==null)
{
jichang="";
}
jichang=codeString(jichang);

String huoche=request.getParameter("huoche");
if(huoche==null)
{
huoche="";
}
huoche=codeString(huoche);

String shizhongxin=request.getParameter("shizhongxin");
if(shizhongxin==null)
{
shizhongxin="";
}
shizhongxin=codeString(shizhongxin);

String jingdian=request.getParameter("jingdian");
if(jingdian==null)
{
jingdian="";
}
jingdian=codeString(jingdian);

String shuoming=request.getParameter("shuoming");
if(shuoming==null)
{
shuoming="";
}
shuoming=codeString(shuoming);

String xingji=request.getParameter("xingji");
if(xingji==null)
{
xingji="";
}
xingji=codeString(xingji);


%>
<%

//上载附件

try
{

mySmartUpload.initialize(pageContext);
mySmartUpload.service(request,response);
mySmartUpload.upload();
mySmartUpload.setMaxFileSize(1);
String fn=fn=mySmartUpload.getFiles().getFile(0).getFileName();
%>
<p><%=fn%>
<%
String tupian="images/"+fn;
session.setAttribute("tupian1",tupian);
mySmartUpload.save("d:/tomcat 5.0/webapps/ROOT/www/images/");//文件保存的目录为upload
out.println("已经成功上传了文件,请查看<a href=images/"+fn+">这里</a>,看文件是否上传成功"+tupian);
}
catch(Exception e)
{
e.printStackTrace();
}
%>

<jsp:setProperty name="binguanjiudian" property="name" value="<%=name%>"/>
<jsp:setProperty name="binguanjiudian" property="jianjie" value="<%=jianjie%>"/>
<jsp:setProperty name="binguanjiudian" property="address" value="<%=address%>"/>
<jsp:setProperty name="binguanjiudian" property="phone" value="<%=phone%>"/>
<jsp:setProperty name="binguanjiudian" property="juti" value="<%=juti%>"/>
<jsp:setProperty name="binguanjiudian" property="jichang" value="<%=jichang%>"/>
<jsp:setProperty name="binguanjiudian" property="huoche" value="<%=huoche%>"/>
<jsp:setProperty name="binguanjiudian" property="shizhongxin" value="<%=shizhongxin%>"/>
<jsp:setProperty name="binguanjiudian" property="jingdian" value="<%=jingdian%>"/>
<jsp:setProperty name="binguanjiudian" property="shuoming" value="<%=shuoming%>"/>
<jsp:setProperty name="binguanjiudian" property="xingji" value="<%=xingji%>"/>
<jsp:setProperty name="binguanjiudian" property="tupian" value="<%=(String)session.getAttribute("tupian1")%>"/>
<%
binguanjiudian.addItem();
String str=(String)session.getAttribute("tupian1");
out.print(str);
%>
帮帮忙啊!!兄弟救人啊 !!
...全文
48 点赞 收藏 1
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
fivesky 2004-09-23
帮你顶
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2004-09-23 09:09
社区公告
暂无公告