日期:2014-05-18 浏览次数:20845 次
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>文件上传!</title>
</head>
<body>
<form action="smartuplaod_demo2.jsp" method="post" enctype="multipart/form-data">
请选择文件<input name="pic" type="file"/><br/>
名字<input type="text" name="name"/>
<input type="submit" value="上传"/>
</form>
</body>
</html>
<%@page import="com.sun.org.apache.xalan.internal.xsltc.trax.SmartTransformerFactoryImpl"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
request.setCharacterEncoding("utf-8");
com.jspsmart.upload.SmartUpload smart = new com.jspsmart.upload.SmartUpload();
smart.initialize(pageContext);
smart.upload();
com.jspsmart.upload.Files files = smart.getFiles();
System.out.println(files.getSize());
System.out.println(smart.save("upload"));
String name = smart.getRequest().getParameter("name");
System.out.println(name);
%>
<%=name %>
通过request直接获取的属性:<%=request.getParameter("name") %>
</body>
</html>