
PrintWriter out = response.getWriter()
int count = 0
// 实例化上传控件对象
SmartUpload su = new SmartUpload()
// 初始化 *** 作
su.initialize(config, request, response)
// 设置上传文件最大字节数
su.setTotalMaxFileSize(100000)
//
try {
//禁止上传指定扩展名的文件
su.setDeniedFilesList("ext,bat,jsp")
} catch (SQLException e1) {
e1.printStackTrace()
}
try {
// 上传文件到服务器
su.upload()
File fileup = new File(request.getRealPath("upload"))
if(!fileup.exists()){
// 创建目录
fileup.mkdir()
}
// 处理多个文件的上传
for(int i = 0i <su.getFiles().getCount()i++){
com.jspsmart.upload.File file = su.getFiles().getFile(i)
if(!file.isMissing()){ // 如果文件有效
// 保存文件到指定上传目录
file.saveAs("/upload/new."+file.getFileExt(), su.SAVE_VIRTUAL)
count = su.save("/upload")
}
}
} catch (SmartUploadException e) {
e.printStackTrace()
}
out.println(count +"file(s) uploaded")
如果你对这个上传组件不了解,最好是先去查查用法。。。
如果对您有帮助,请记得采纳为满意答案,谢谢!祝您生活愉快!
vaela
首先明白在这里复选框有两个关键属性,1、name。2、value。用两个JSP来做
第一个页面多个复选框name值保持一致,这样才构成一组,放在表单里。提交到另外一个JSP页面后用request.getParameterValues()得到这个组value值组成的集合。所以getParameterValues返回的是一个String[]。然后把String[]的值保存到数据库
注:request.getParameterValues()参数是name的值
double d=-3.5738402433531764string sql = "update Table1 set [Number]=@p1 where ID=1"
SqlConnection conn = new SqlConnection()
conn.ConnectionString = "Data Source=.\\SQLExpressIntegrated Security=trueAttachDbFilename=|DataDirectory|\\Database.mdfUser Instance=true"
SqlCommand cmd = new SqlCommand(sql, conn)
SqlParameter sp = new SqlParameter("@p1",SqlDbType.Decimal,38,18)
sp.Value=d
cmd.Parameters.Add(sp)
try
{
conn.Open()
return(cmd.ExecuteNonQuery())
}
catch (Exception)
{
return -1
throw
}
finally
{
conn.Close()
}
Number字段建议用Decimal(38,19)类型存储。
C#程序中查询数据时建议用Double或Decimal。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)