include -- just for myself 本帖最后由 wj6659815 于 2012-03-28 23:34:25 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <meta http-equiv="Content-Type" content="text/html; charset=gb2312"><!--body { FONT-SIZE: 9pt; margin-left:0px; margin-top:0px; SCROLLBAR-FACE-COLOR: #622949; SCROLLBAR-HIGHLIGHT-COLOR: #ffffff; SCROLLBAR-SHADOW-COLOR: #fcfcfc; COLOR: #000000; SCROLLBAR-3DLIGHT-COLOR: #ececec; SCROLLBAR-ARROW-COLOR: #ffffff; SCROLLBAR-TRACK-COLOR: #ececec; SCROLLBAR-DARKSHADOW-COLOR: #999966;}.topA{ font-size:9pt;color:#63284A; text-decoration:none;}.topA:hover{ font-size: 9pt; color: #000000; text-decoration:underline}a { font-size: 9pt; text-decoration: none; color: #6E6E6E; noline:expression(this.onfocus=this.blur);}a:hover { font-size: 9pt; color: #410E3D; text-decoration:underline}.word_white { font-size: 9pt; color: #FFFFFF;}.word_purple { font-size: 9pt; color: #BB71A6;}.word_menuHead{ font-size: 9pt; color: #62294A; font-weight:bold;}.topTD{ font-size: 9pt; color: #63284A;}td{ font-size: 9pt; color: #655555;}input{ font-family: "宋体"; font-size: 9pt; color: #333333; background-color:#F9EFF6;}body { margin-left: 0px; margin-top: 20px; margin-right: 0px; margin-bottom: 0px; }.textarea { font-family: "宋体"; font-size: 9pt; color: #333333; border: 1px solid #999999;}.btn_bg { background-image:url(../images/btn_bg.jpg); border:#436E9B thin 1px; width:48px; height:20px;padding:4px; color:#FFFFFF;}.tableBorder_B{ border:1px dotted #E59FD5; border-left-style:none; border-right-style:none; border-Top-style:none; }.tableBorder_R{ border:1px dotted #622949; border-left-style:none; border-bottom-style:none; border-Top-style:none; }.tableBorder_T{ border:1px dotted #622949; border-left-style:none; border-right-style:none; border-bottom-style:none; }.noborder{border-style:none;background-color:#FFFFFF;}--> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"><!--.topA{ font-size:9pt;color:#63284A; text-decoration:none;}.topA:hover{ font-size: 9pt; color: #000000; text-decoration:underline}a { font-size: 9pt; text-decoration: none; color: #6E6E6E; noline:expression(this.onfocus=this.blur);}a:hover { font-size: 9pt; color: #000000; text-decoration:underline}.topTD{ font-size: 9pt; color: #63284A;}td{ font-size: 9pt; color: #655555;}input{ font-family: "宋体"; font-size: 9pt; color: #333333; background-color:#F9EFF6;}body { margin-left: 0px; margin-top: 20px; margin-right: 0px; margin-bottom: 0px; }.textarea { font-family: "宋体"; font-size: 9pt; color: #333333; border: 1px solid #999999;}.btn_bg { background-image:url(../images/btn_bg.jpg); border:#436E9B thin 1px; width:48px; height:20px;padding:4px; color:#FFFFFF;}--> Struts2上传文件upload.jsp<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%@ taglib prefix="s" uri="/struts-tags" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> …… <body> <s:form action="upload.action" enctype="multipart/form-data"> <s:file name="img" ></s:file> <s:submit name="sub" value="upLoad"></s:submit> </s:form> </body></html>UploadAction:public class UploadFileAction extends ActionSupport { private File img; //img变量用于接收上传的文件 private String imgFileName;//上传的文件名,即img+“FileName” private String imgContextType; public File getImg() { return img; } public void setImg(File img) { this.img = img; } public String getImgFileName() { return imgFileName; } public void setImgFileName(String imgFileName) { this.imgFileName = imgFileName; } public String getImgContextType() { return imgContextType; } public void setImgContextType(String imgContextType) { this.imgContextType = imgContextType; } @Override public String execute() throws Exception { System.out.println("<><><>上传……<><><>"); File imageFile = new File(ServletActionContext.getServletContext().getRealPath("/upload")+ "/"+imgFileName); //上传的文件保存的路径 InputStream in = new FileInputStream(img); //建立读取上传文件的输入流 OutputStream out = new FileOutputStream(imageFile); //建立指向目标位置的输出流 byte[] buff = new byte[1024]; int len = 0; while ((len = in.read(buff)) != -1) { //读取源文件并写入到目标文件夹中 out.write(buff, 0, len); } in.close(); out.close(); return SUCCESS; }} JSP页面中文传值乱码问题。。。 jsp用户注册出错 100分求解决树型列表问题 多个超链接组合查询 参数该怎么传 刚刚学习问两个问题!谢谢! 数据库连接池的问题,连接池对象为静态变量有问题么 循环读取表中数据,只能读取一条记录。附代码,请看看。(jsp)。谢谢 怎么在jsp和servlet里使用自己编的类???怎么导入? 一个日期转换的方法 (JSP)Resin表单提交中的汉字显示乱码问题? org.hibernate.collection.PersistentSet cannot be cast to com.iprecare.entity.Per ssh表单提交问题
<!--
body {
FONT-SIZE: 9pt;
margin-left:0px;
margin-top:0px;
SCROLLBAR-FACE-COLOR: #622949;
SCROLLBAR-HIGHLIGHT-COLOR: #ffffff;
SCROLLBAR-SHADOW-COLOR: #fcfcfc; COLOR: #000000;
SCROLLBAR-3DLIGHT-COLOR: #ececec;
SCROLLBAR-ARROW-COLOR: #ffffff;
SCROLLBAR-TRACK-COLOR: #ececec;
SCROLLBAR-DARKSHADOW-COLOR: #999966;
}.topA{
font-size:9pt;color:#63284A;
text-decoration:none;
}
.topA:hover{
font-size: 9pt; color: #000000;
text-decoration:underline
}
a {
font-size: 9pt; text-decoration: none; color: #6E6E6E;
noline:expression(this.onfocus=this.blur);
}
a:hover {
font-size: 9pt; color: #410E3D;
text-decoration:underline
}
.word_white {
font-size: 9pt;
color: #FFFFFF;
}
.word_purple {
font-size: 9pt;
color: #BB71A6;
}
.word_menuHead{
font-size: 9pt;
color: #62294A;
font-weight:bold;
}
.topTD{
font-size: 9pt; color: #63284A;
}
td{
font-size: 9pt; color: #655555;
}
input{
font-family: "宋体";
font-size: 9pt;
color: #333333;
background-color:#F9EFF6;}
body {
margin-left: 0px;
margin-top: 20px;
margin-right: 0px;
margin-bottom: 0px;
}
.textarea {
font-family: "宋体";
font-size: 9pt;
color: #333333;
border: 1px solid #999999;
}
.btn_bg {
background-image:url(../images/btn_bg.jpg); border:#436E9B thin 1px;
width:48px;
height:20px;padding:4px;
color:#FFFFFF;
}
.tableBorder_B{
border:1px dotted #E59FD5;
border-left-style:none;
border-right-style:none;
border-Top-style:none;
}
.tableBorder_R{
border:1px dotted #622949;
border-left-style:none;
border-bottom-style:none;
border-Top-style:none;
}
.tableBorder_T{
border:1px dotted #622949;
border-left-style:none;
border-right-style:none;
border-bottom-style:none;
}
.noborder{
border-style:none;
background-color:#FFFFFF;
}
-->
<!--
.topA{
font-size:9pt;color:#63284A;
text-decoration:none;
}
.topA:hover{
font-size: 9pt; color: #000000;
text-decoration:underline
}
a {
font-size: 9pt; text-decoration: none; color: #6E6E6E;
noline:expression(this.onfocus=this.blur);
}
a:hover {
font-size: 9pt; color: #000000;
text-decoration:underline
}
.topTD{
font-size: 9pt; color: #63284A;
}
td{
font-size: 9pt; color: #655555;
}
input{
font-family: "宋体";
font-size: 9pt;
color: #333333;
background-color:#F9EFF6;}
body {
margin-left: 0px;
margin-top: 20px;
margin-right: 0px;
margin-bottom: 0px;
}
.textarea {
font-family: "宋体";
font-size: 9pt;
color: #333333;
border: 1px solid #999999;
}
.btn_bg {
background-image:url(../images/btn_bg.jpg); border:#436E9B thin 1px;
width:48px;
height:20px;padding:4px;
color:#FFFFFF;
}-->
upload.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
……
<body>
<s:form action="upload.action" enctype="multipart/form-data">
<s:file name="img" ></s:file>
<s:submit name="sub" value="upLoad"></s:submit>
</s:form>
</body>
</html>UploadAction:
public class UploadFileAction extends ActionSupport {
private File img; //img变量用于接收上传的文件
private String imgFileName;//上传的文件名,即img+“FileName”
private String imgContextType;
public File getImg() {
return img;
}
public void setImg(File img) {
this.img = img;
}
public String getImgFileName() {
return imgFileName;
}
public void setImgFileName(String imgFileName) {
this.imgFileName = imgFileName;
}
public String getImgContextType() {
return imgContextType;
}
public void setImgContextType(String imgContextType) {
this.imgContextType = imgContextType;
}
@Override
public String execute() throws Exception {
System.out.println("<><><>上传……<><><>");
File imageFile = new File(ServletActionContext.getServletContext().getRealPath("/upload")+
"/"+imgFileName); //上传的文件保存的路径
InputStream in = new FileInputStream(img); //建立读取上传文件的输入流
OutputStream out = new FileOutputStream(imageFile); //建立指向目标位置的输出流
byte[] buff = new byte[1024];
int len = 0;
while ((len = in.read(buff)) != -1) { //读取源文件并写入到目标文件夹中
out.write(buff, 0, len);
}
in.close();
out.close();
return SUCCESS;
}
}