主题:html传递jsp页面中文乱码,急
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>添加图片新闻 </title>
</head>
<body>
<form name="test" action="do_picnews.jsp" method="post" enctype="multipart/form-data" onSubmit="javascript:KindSubmit();">
<table border="0">
<tr>
<td> 文章标题:<input type="text" name="title3" size=20></td>
</tr>
<tr>
<td>选择图片:<input type="file" name="file2" size="15"></td>
</tr>
<td>文章内容:<div style="font-size:12px;margin-bottom:5px;"></div>
<input type="hidden" name="content3" value="">
<script type="text/javascript" src="./KindEditor.js"></script>
<script type="text/javascript">
var editor = new KindEditor("editor");
editor.hiddenName = "content3";
editor.editorWidth = "600px";
editor.editorHeight = "400px";
editor.show();
function KindSubmit() {
editor.data();
}
</script> </td>
</tr>
</table>
<div align="center">
<input type="submit" value="Submit">
</div>
</form>
</body>
</html>
<%@ page contentType="text/html; charset=utf-8" language="java" import="infoweb1.DBConnect" import="java.util.Calendar" import="java.text.DateFormat"%>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>上载附件 </title>
</head>
<body>
<center>在上传文件...
<%
request.setCharacterEncoding("utf-8");
Calendar c = Calendar.getInstance();//可以对每个时间域单独修改
int year = c.get(Calendar.YEAR);
int month1 = c.get(Calendar.MONTH);
int month = month1 + 1;
int date1 = c.get(Calendar.DATE);
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
int second = c.get(Calendar.SECOND);
System.out.println(year + "-" + month + "-" + date1 );
String date5 = year + "-" + month + "-" + date1 ;
//System.out.println(date5);
java.util.Date dt=null;
DateFormat df=DateFormat.getDateInstance();
//上载附件
try
{
DBConnect DBC1 = new DBConnect();
mySmartUpload.initialize(pageContext);
mySmartUpload.upload();
String title2 = mySmartUpload.getRequest().getParameter("title3");
String content1 = mySmartUpload.getRequest().getParameter("content3");
mySmartUpload.save("/upload");
String fn = mySmartUpload.getFiles().getFile(0).getFileName();
mySmartUpload.getFiles().getFile(0).saveAs("/upload/."+fn) ;
mySmartUpload.save("/upload");//文件保存的目录为upload
System.out.println(fn);
String path = (fn);
System.out.println(path);
dt=df.parse(date5);
String str1 = "insert into doc (path, time,title,content,type) values('"+path+"', '"+df.format(dt)+"','"+title2+"','"+content1+"','"+2+"')";
System.out.println(str1);
DBC1.excuteUpdate(str1);
System.out.println(df.format(dt));
out.println("已经成功上传了文件");
}
catch(Exception e)
{
e.printStackTrace();
}
%>
<a href=pic_news.html>继续添加</a>
</body>
</html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>添加图片新闻 </title>
</head>
<body>
<form name="test" action="do_picnews.jsp" method="post" enctype="multipart/form-data" onSubmit="javascript:KindSubmit();">
<table border="0">
<tr>
<td> 文章标题:<input type="text" name="title3" size=20></td>
</tr>
<tr>
<td>选择图片:<input type="file" name="file2" size="15"></td>
</tr>
<td>文章内容:<div style="font-size:12px;margin-bottom:5px;"></div>
<input type="hidden" name="content3" value="">
<script type="text/javascript" src="./KindEditor.js"></script>
<script type="text/javascript">
var editor = new KindEditor("editor");
editor.hiddenName = "content3";
editor.editorWidth = "600px";
editor.editorHeight = "400px";
editor.show();
function KindSubmit() {
editor.data();
}
</script> </td>
</tr>
</table>
<div align="center">
<input type="submit" value="Submit">
</div>
</form>
</body>
</html>
<%@ page contentType="text/html; charset=utf-8" language="java" import="infoweb1.DBConnect" import="java.util.Calendar" import="java.text.DateFormat"%>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>上载附件 </title>
</head>
<body>
<center>在上传文件...
<%
request.setCharacterEncoding("utf-8");
Calendar c = Calendar.getInstance();//可以对每个时间域单独修改
int year = c.get(Calendar.YEAR);
int month1 = c.get(Calendar.MONTH);
int month = month1 + 1;
int date1 = c.get(Calendar.DATE);
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
int second = c.get(Calendar.SECOND);
System.out.println(year + "-" + month + "-" + date1 );
String date5 = year + "-" + month + "-" + date1 ;
//System.out.println(date5);
java.util.Date dt=null;
DateFormat df=DateFormat.getDateInstance();
//上载附件
try
{
DBConnect DBC1 = new DBConnect();
mySmartUpload.initialize(pageContext);
mySmartUpload.upload();
String title2 = mySmartUpload.getRequest().getParameter("title3");
String content1 = mySmartUpload.getRequest().getParameter("content3");
mySmartUpload.save("/upload");
String fn = mySmartUpload.getFiles().getFile(0).getFileName();
mySmartUpload.getFiles().getFile(0).saveAs("/upload/."+fn) ;
mySmartUpload.save("/upload");//文件保存的目录为upload
System.out.println(fn);
String path = (fn);
System.out.println(path);
dt=df.parse(date5);
String str1 = "insert into doc (path, time,title,content,type) values('"+path+"', '"+df.format(dt)+"','"+title2+"','"+content1+"','"+2+"')";
System.out.println(str1);
DBC1.excuteUpdate(str1);
System.out.println(df.format(dt));
out.println("已经成功上传了文件");
}
catch(Exception e)
{
e.printStackTrace();
}
%>
<a href=pic_news.html>继续添加</a>
</body>
</html>