addUser.jsp
......................
<form action="chaddUser.jsp?rankId=<%=rankId%>" method="post" name="form1" enctype="multipart/form-data">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<%
int index = -1;
%>
<tr>
<td></td>
<td>选择角色:</td>
<td>项目名称</td>
<td>角 色</td>
</tr>
<tr>
<td height="8" colspan="6"></td>
</tr>
<%
sql="SELECT pName,pID FROM project";
rs=stmt.executeQuery(sql);
while(rs.next())
{
int pID=rs.getInt("pID");
String pName=rs.getString("pName");
%>
<tr>
<td></td>
<td></td>
<td width="156"><%=pName%></td>
<td width="409">
<%
index++;
%>
<input type="hidden" name="pID[<%=index%>]" value="<%=pID%>">
<select name="projectRole[<%=index%>]">
<option value="4" selected>None</option>
<option value="1">管理员</option>
<option value="2">编辑者</option>
<option value="3">浏览者</option>
</select>
</td>
</tr>
<%
}
%>
.............................
chaddUser.jsp
..........
ArrayList pIDs = (ArrayList)session.getAttribute("pID");
ArrayList projectRoles = (ArrayList)session.getAttribute("projectRole");
if(pIDs!=null&&projectRoles!=null)
{
for (int counter = 0; counter < pIDs.size()&&counter < projectRoles.size (); counter++ )
{
pID = (String)pIDs.get(counter);
projectRole = (String)projectRoles.get(counter);
sql1="INSERT INTO person_role(person_id,project_id,role_id) VALUES('"+uId+"','"+pID+"','"+projectRole+"')";
stmt1.executeQuery(sql1);
valid=true;
}
}
................
问题:我想把addUser.jsp中的项目ID(pID[<%=index%>])和项目角色
(projectRole[%=index%])传给chaddUser.jsp。但是现在不知道如何获取它们的值。其中的chaddUser.jsp中的ArrayList是我自己写的
请各位高人多多指点如何写这个代码。。
......................
<form action="chaddUser.jsp?rankId=<%=rankId%>" method="post" name="form1" enctype="multipart/form-data">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<%
int index = -1;
%>
<tr>
<td></td>
<td>选择角色:</td>
<td>项目名称</td>
<td>角 色</td>
</tr>
<tr>
<td height="8" colspan="6"></td>
</tr>
<%
sql="SELECT pName,pID FROM project";
rs=stmt.executeQuery(sql);
while(rs.next())
{
int pID=rs.getInt("pID");
String pName=rs.getString("pName");
%>
<tr>
<td></td>
<td></td>
<td width="156"><%=pName%></td>
<td width="409">
<%
index++;
%>
<input type="hidden" name="pID[<%=index%>]" value="<%=pID%>">
<select name="projectRole[<%=index%>]">
<option value="4" selected>None</option>
<option value="1">管理员</option>
<option value="2">编辑者</option>
<option value="3">浏览者</option>
</select>
</td>
</tr>
<%
}
%>
.............................
chaddUser.jsp
..........
ArrayList pIDs = (ArrayList)session.getAttribute("pID");
ArrayList projectRoles = (ArrayList)session.getAttribute("projectRole");
if(pIDs!=null&&projectRoles!=null)
{
for (int counter = 0; counter < pIDs.size()&&counter < projectRoles.size (); counter++ )
{
pID = (String)pIDs.get(counter);
projectRole = (String)projectRoles.get(counter);
sql1="INSERT INTO person_role(person_id,project_id,role_id) VALUES('"+uId+"','"+pID+"','"+projectRole+"')";
stmt1.executeQuery(sql1);
valid=true;
}
}
................
问题:我想把addUser.jsp中的项目ID(pID[<%=index%>])和项目角色
(projectRole[%=index%])传给chaddUser.jsp。但是现在不知道如何获取它们的值。其中的chaddUser.jsp中的ArrayList是我自己写的
请各位高人多多指点如何写这个代码。。
解决方案 »
- 问一个select语句意思
- request.getParameter的问题
- 现在springMVC用的多吗?
- jsp调试问题,还请大侠们帮帮忙!
- 从数据库中读取一个字段,但不想都显示,怎么做?
- 刚找到工作,特来求教,tomcat+jBuilder+DB2如何配置整个开发系统,
- Java语言如何实现csdn论坛界面左边框架的树状层次(+/-)结构?
- :::::::::::::::: 关于jsp 的 include 方法的疑问 ::::::::::::::::::::::
- javamail api 开发邮件系统的问题
- web项目在Tomcat运行到org.springframework.web.context.ContextLoader 就不运行了
- 急!javabean编译错误!
- 哪位大侠有SmartUpload组件
<input type="hidden" name="pID" value="<%=pID%>">name必须是相同的然后
String[] pIDs = request.getParameterValues("pID");
再问一下怎样把这个数组值插入到数据库中,
用这个可以吗:
sql1="INSERT INTO person_role(person_id,project_id,role_id) VALUES('"+uId+"','"+pIDs+"','"+projectRoles+"')";
请各位多多指点..............
这个方法只对checkbox有用,在这个数组中是没有用的,请各位高手能不能指点一下啊,
我已经调试了2天了...........................
//先求出总数,这个你应该能求出来之后
int zong=10;
String shuzu[]=new String[zong];
for(int i=0;i<zong;i++)
{
shuzu[i]=request.getParameter("pID"+shuzu[i]);
String sql1="INSERT INTO person_role(project_id) VALUES("+shuzu[i]+")";
stmt1.executeQuery(sql1);
}
//应该就是这个意思,你琢磨琢磨!
%>
的值呢