主题:关于上传的问题。。急!急!
程序如下。。
我的问题就是,为什么我的值传不过去!
程序1:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.hust.space.photoType.*" %>
<jsp:useBean id="photoType" class="com.hust.space.photoType.PhotoTypeService"/>
<%!
String showStr(HttpServletRequest request,String name){
String value = (String)request.getAttribute(name);
if(value!=null){
return "<font size='2' color='red'>"+value+"</font>";
}
return "";
}
%>
<html>
<head>
<title>相片上传</title>
</head>
<body>
<center>
<h4>个人空间----相片管理</h4>
<hr>
<form action="Uptext.jsp" method="post" enctype="multipart/form-data">
<table width="575" border="1">
<tr>
<td width="147" height="50">上传文件地址:</td>
<td width="258"><input type="file" name="file"></td>
</tr>
<tr>
<td height="48">文件重命名:</td>
<td><input type="text" name="newName"></td>
</tr>
<tr>
<td height="83">上传类型:</td>
<td>
<%
String userId = (String) session.getAttribute("userId");
ArrayList<PhotoType> list = new ArrayList<PhotoType>();
list = (ArrayList)photoType.getPhotoTypeById(userId);
for(PhotoType pt:list){
%>
<input type="radio" name="photoType" value="<%=pt.getPhotoTypeId() %>">
<%=pt.getPhotoTypeName() %>
<%} %></td>
</tr>
<tr>
<td height="57" colspan="3" align="center"><input type="submit" name="submit" value="上传"></td>
</tr>
</table>
<br>
</form>
</center>
</body>
</html>
程序2:
<%@ page language="java" pageEncoding="UTF-8"%>
<jsp:useBean id="su" class="com.jspsmart.upload.SmartUpload"></jsp:useBean>
<html>
<head>
<title>My JSP 'Uptext.jsp' starting page</title>
</head>
<body>
<%
su.initialize(pageContext);
su.setAllowedFilesList("JPG,GIF,gif,jpg");
su.upload();
su.save("/image");
%>
<small>类型:<%=su.getRequest().getParameter("photoType")%></small>
<small>名字:<%=su.getRequest().getParameter("newName") %></small>
文件:<%=su.getRequest().getParameter("file") %>
</body>
</html>
等到结果为:类型:null 名字:1234 文件:null
为什么得不到传过来的值啊!!!
各位前辈门指点下
我的问题就是,为什么我的值传不过去!
程序1:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.hust.space.photoType.*" %>
<jsp:useBean id="photoType" class="com.hust.space.photoType.PhotoTypeService"/>
<%!
String showStr(HttpServletRequest request,String name){
String value = (String)request.getAttribute(name);
if(value!=null){
return "<font size='2' color='red'>"+value+"</font>";
}
return "";
}
%>
<html>
<head>
<title>相片上传</title>
</head>
<body>
<center>
<h4>个人空间----相片管理</h4>
<hr>
<form action="Uptext.jsp" method="post" enctype="multipart/form-data">
<table width="575" border="1">
<tr>
<td width="147" height="50">上传文件地址:</td>
<td width="258"><input type="file" name="file"></td>
</tr>
<tr>
<td height="48">文件重命名:</td>
<td><input type="text" name="newName"></td>
</tr>
<tr>
<td height="83">上传类型:</td>
<td>
<%
String userId = (String) session.getAttribute("userId");
ArrayList<PhotoType> list = new ArrayList<PhotoType>();
list = (ArrayList)photoType.getPhotoTypeById(userId);
for(PhotoType pt:list){
%>
<input type="radio" name="photoType" value="<%=pt.getPhotoTypeId() %>">
<%=pt.getPhotoTypeName() %>
<%} %></td>
</tr>
<tr>
<td height="57" colspan="3" align="center"><input type="submit" name="submit" value="上传"></td>
</tr>
</table>
<br>
</form>
</center>
</body>
</html>
程序2:
<%@ page language="java" pageEncoding="UTF-8"%>
<jsp:useBean id="su" class="com.jspsmart.upload.SmartUpload"></jsp:useBean>
<html>
<head>
<title>My JSP 'Uptext.jsp' starting page</title>
</head>
<body>
<%
su.initialize(pageContext);
su.setAllowedFilesList("JPG,GIF,gif,jpg");
su.upload();
su.save("/image");
%>
<small>类型:<%=su.getRequest().getParameter("photoType")%></small>
<small>名字:<%=su.getRequest().getParameter("newName") %></small>
文件:<%=su.getRequest().getParameter("file") %>
</body>
</html>
等到结果为:类型:null 名字:1234 文件:null
为什么得不到传过来的值啊!!!
各位前辈门指点下