jsp把图片写到数据库的代码,多种写法
由于要做上传 就找了个例子 留着参考
上传:需要smartupload组件
import com.jspsmart.upload.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
/**
* 上传公共类,对SmartUpload进行了封装
* @author askr
* @version 1.0
*/
public class MyUpload
{
/**
*保存上传的文件
*
* @param request 页面请求对象
* @param response 页面响应对象
* @param config 页面配置对象
* @param mainName 赋予的主文件名
* @param savePhyPath 文件保存的文件夹
* @param maxSizePool 上传时允许的最大容量,单位:KB
* @param maxSizeAllowed 文件上传时允许的最大大小,单位:KB
* @param formatListAllowed 允许的文件格式,以逗号分隔的字符串序列
* @return 如果没有上传,返回空字符串,否则,是保存后的文件名
*/
public static String SaveUpload(HttpServletRequest request,
HttpServletResponse response,ServletConfig config,
String mainName,String savePhyPath,int maxSizePool,int maxSizeAllowed,
String formatListAllowed)
{
SmartUpload upl = new SmartUpload();
com.jspsmart.upload.File f=null;
try {
upl.init(config); //config是隐含内置对象
upl.service(request, response);
// upl.setAllowedFilesList(formatListAllowed);
upl.setTotalMaxFileSize(maxSizePool * 1024); //字节
upl.upload();
f = upl.getFiles().getFile(0);
String name = f.getFileName();
if (f.getSize() == 0) {
return "";
}
if (f.
相关文档:
今天在学习jsp中数据库的使用时,遇到一个很奇怪的情况(至少现在看来是的)。jsp中连接mysql数据库,开启mysql数据库后,在jsp页面中嵌入的java连接mysql数据库的那几句代码。好像 Class.forName("org.gjt.mm.mysql.Driver");没起到作用,只需要Connection con=DriverManager.getConnection("jdbc:mysql://localhost/test? ......
●jsp连接MySQL数据库
testmysql.jsp如下:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://localhost/softforum?
user=soft&pas ......
最基本的乱码问题
这个乱码问题是最简单的乱码问题。一般新会出现。就是页面编码不一致导致的乱码。
Html代码:
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=iso8859-1"%>
<html>
<head>
<title ......
1.FCKeditor 介绍
FCKeditor 这个开源的HTML 文本编辑器可以让web 程序拥有如MS Word 这样强大的编辑功能,.FCKeditor 支持当前流行的浏览器。
2.准备工作:
环境:winddows XP、tomcat6.0、JDK1.6
下载:
1):FCKeditor_2.6.4.zip
地址:http://nchc.dl.sourceforge.net/sourceforge/fckeditor/FCKeditor_2.6.4.zip ......