jsp页面中的代码如下:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.course.dao.DirectoryDAO"%>
<%@page import="com.course.po.Directory"%><%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>添加资源</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<link rel="stylesheet" rev="stylesheet" href="css/style.css" type="text/css" media="all" />
<style type="text/css">
<!--
.atten {font-size:12px;font-weight:normal;color:#F00;}
-->
</style>
<%! int pid; %>
<script type="text/javascript">
function reload(value)
{
location.href="<%=path%>/admin/addSource.jsp?id="+value;
}
</script>
</head>
<body class="ContentBody">
<center>
<table width="99%" border="0" cellpadding="0" cellspacing="0" class="CContent">
<div id="source">
<h2>添加资源</h2>
<s:actionerror/>
<form name="form1" method="post" action="uploadsource.action" enctype="multipart/form-data">
<table>
<tr>
<td align="right">大类类型</td>
<td><select name="bigtype" id="big" onChange="reload(this.value)" >
<%
String id=request.getParameter("id");
if(id==null)
id="-1";
DirectoryDAO cdao=new DirectoryDAO();
ArrayList<Directory> arr=cdao.getDirectoryByPidForSource(0);
for(Directory c:arr)
{
if(id.equals("-1"))
id=String.valueOf(c.getDirectoryId()); //第一次进入这个页面时,获得第一个大类的ID
%>
<option <%=(id.equals(String.valueOf(c.getDirectoryId()))?"selected":"")%> value="<%=c.getDirectoryId()%>"><%=c.getDirectoryName()%></option>
<%
}
%>
</select>
</td>
</tr>
<tr>
<td align="right">小类类型</td>
<td>
<select name="smalltype" id="small">
<%
String smallid=request.getParameter("smalltype");
if(smallid==null) smallid="-1";
DirectoryDAO cdao1=new DirectoryDAO();
ArrayList<Directory> arr1=cdao1.getDirectoryByPidForSource(Integer.parseInt(id));
for(Directory c:arr1)
{
%>
<option <%=(smallid.equals(String.valueOf(c.getDirectoryId()))?"selected":"")%> value="<%=c.getDirectoryId()%>"><%=c.getDirectoryName()%></option>
<%
}
%>
</select>
</td>
</tr>
<tr>
<td align="right">资源文件</td>
<td><input type="file" name="myFile"></td>
<td>只允许上传swf格式的文件,若不是请先转换</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="Submit" value="提交" >
</td>
</tr>
<tr>
<td colspan="2" > </td>
</tr>
</table>
</form>
</table>
</center>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.course.dao.DirectoryDAO"%>
<%@page import="com.course.po.Directory"%><%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>添加资源</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<link rel="stylesheet" rev="stylesheet" href="css/style.css" type="text/css" media="all" />
<style type="text/css">
<!--
.atten {font-size:12px;font-weight:normal;color:#F00;}
-->
</style>
<%! int pid; %>
<script type="text/javascript">
function reload(value)
{
location.href="<%=path%>/admin/addSource.jsp?id="+value;
}
</script>
</head>
<body class="ContentBody">
<center>
<table width="99%" border="0" cellpadding="0" cellspacing="0" class="CContent">
<div id="source">
<h2>添加资源</h2>
<s:actionerror/>
<form name="form1" method="post" action="uploadsource.action" enctype="multipart/form-data">
<table>
<tr>
<td align="right">大类类型</td>
<td><select name="bigtype" id="big" onChange="reload(this.value)" >
<%
String id=request.getParameter("id");
if(id==null)
id="-1";
DirectoryDAO cdao=new DirectoryDAO();
ArrayList<Directory> arr=cdao.getDirectoryByPidForSource(0);
for(Directory c:arr)
{
if(id.equals("-1"))
id=String.valueOf(c.getDirectoryId()); //第一次进入这个页面时,获得第一个大类的ID
%>
<option <%=(id.equals(String.valueOf(c.getDirectoryId()))?"selected":"")%> value="<%=c.getDirectoryId()%>"><%=c.getDirectoryName()%></option>
<%
}
%>
</select>
</td>
</tr>
<tr>
<td align="right">小类类型</td>
<td>
<select name="smalltype" id="small">
<%
String smallid=request.getParameter("smalltype");
if(smallid==null) smallid="-1";
DirectoryDAO cdao1=new DirectoryDAO();
ArrayList<Directory> arr1=cdao1.getDirectoryByPidForSource(Integer.parseInt(id));
for(Directory c:arr1)
{
%>
<option <%=(smallid.equals(String.valueOf(c.getDirectoryId()))?"selected":"")%> value="<%=c.getDirectoryId()%>"><%=c.getDirectoryName()%></option>
<%
}
%>
</select>
</td>
</tr>
<tr>
<td align="right">资源文件</td>
<td><input type="file" name="myFile"></td>
<td>只允许上传swf格式的文件,若不是请先转换</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="Submit" value="提交" >
</td>
</tr>
<tr>
<td colspan="2" > </td>
</tr>
</table>
</form>
</table>
</center>
</body>
</html>
解决方案 »
- build.xml无法编译--小弟没积分了 求救
- 我在tomcat里的Server.xml部署web项目报Error instantiating servlet class
- sql语句:insert into c (name,age) values(?,?);id自增,然后给他赋值,但是一直报错
- apache+resin服务器设定问题
- 把一个web应用的所有*.class文件打包成jar文件,部署在lib目录中,而不是部署在WEB-INF\classes目录中,这样可以吗?
- 过滤类来过滤请求,但是只能过滤到jsp,action没有办法过滤
- 套接字重新创建失败
- 求教elipse3M+lomboz+tomcat5的配置问题~~~~~~~~~~~~~~~~~~~~~~~~~
- 求救!关于jsp包含文件问题
- 聊天室谈出对话框
- Bean property 'userService' is not writable or has an invalid setter method. Doe
- java web 批量打印
我就是按照你说的这个方法做的,但是smalltype依然获取到的是null,代码中的大类和小类意思主要就是实现目录对应的一级和二级,当一级目录改变时,二级目录也跟着改变,然后是要在二级目录下上传文件,在action中需要获取二级目录的值,也就是smalltype,不知道为什么像你那样说的,获取不到呢?