如何获取前段复选框的值并传到后台插入数据库?SpringMVC 非常着急!! 5
<tdalign="left"><inputtype="checkbox"name="week"value="1"/>星期一<inputtype="checkbox"na...
<td align="left">
<input type="checkbox" name="week" value="1"/>星期一
<input type="checkbox" name="week" value="2"/>星期二
<input type="checkbox" name="week" value="3"/>星期三
<input type="checkbox" name="week" value="4"/>星期四
<input type="checkbox" name="week" value=5""/>星期五
<input type="checkbox" name="week" value="6"/>星期六
<input type="checkbox" name="week" value="7"/>星期日
</td>
前段代码
后台controller
@RequestMapping(value ="/Addroom", method = RequestMethod.GET)
public String Addroom(ModelMap modile,HttpServletRequest request,HttpServletResponse response)
{
String name=request.getParameter("Rname");
String mrcapacity=request.getParameter("operatorId");
String dep_id=request.getParameter("depIds");
QlOfficeMeetingRoom room=new QlOfficeMeetingRoom();
room.setMrId(room.getMrId());
room.setMrName(name);
room.setMrCapacity(mrcapacity);
room.setMrDesc("text");
room.setMrPlace("text");
room.setDepId(dep_id);
room.setSecretUserId("1");
room.setOperator("test");
String[] checkbox=new String[]{};
for(int i =0;i<checkbox.length;i++)
{
checkbox[i]=request.getParameter("week");
room.setApplyWeekdays(checkbox[i]);
}
int num =roomdao.addroom(room);
return "addroom";
}
要求选中就传值不选中不穿 展开
<input type="checkbox" name="week" value="1"/>星期一
<input type="checkbox" name="week" value="2"/>星期二
<input type="checkbox" name="week" value="3"/>星期三
<input type="checkbox" name="week" value="4"/>星期四
<input type="checkbox" name="week" value=5""/>星期五
<input type="checkbox" name="week" value="6"/>星期六
<input type="checkbox" name="week" value="7"/>星期日
</td>
前段代码
后台controller
@RequestMapping(value ="/Addroom", method = RequestMethod.GET)
public String Addroom(ModelMap modile,HttpServletRequest request,HttpServletResponse response)
{
String name=request.getParameter("Rname");
String mrcapacity=request.getParameter("operatorId");
String dep_id=request.getParameter("depIds");
QlOfficeMeetingRoom room=new QlOfficeMeetingRoom();
room.setMrId(room.getMrId());
room.setMrName(name);
room.setMrCapacity(mrcapacity);
room.setMrDesc("text");
room.setMrPlace("text");
room.setDepId(dep_id);
room.setSecretUserId("1");
room.setOperator("test");
String[] checkbox=new String[]{};
for(int i =0;i<checkbox.length;i++)
{
checkbox[i]=request.getParameter("week");
room.setApplyWeekdays(checkbox[i]);
}
int num =roomdao.addroom(room);
return "addroom";
}
要求选中就传值不选中不穿 展开
2个回答
展开全部
@RequestMapping(value ="/Addroom", method = RequestMethod.GET)
public String Addroom(String week){
}
接收的参数直接告诉它就行,接收到数据以 , 号分隔的字符串
public String Addroom(String week){
}
接收的参数直接告诉它就行,接收到数据以 , 号分隔的字符串
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
request.getParameterValues("week");这个就可以啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询