当我在页面上点击添加按扭时提交到action这个方法,就报这个错:public ActionForward addTabuInfo(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response)throws Exception{
int firstDrugno = Integer.parseInt(request.getParameter("firstDrugno"));
int secondDrugno = Integer.parseInt(request.getParameter("secondDrugno"));
//根据id查出相关信息
String hql = "from InjectionTabu i where i.firstDrug.id ="+firstDrugno+" and i.secondDrug.id = "+secondDrugno+"";
List list = drugInjectionTabuBiz.findByHql(hql);
if(list.size() != 0){
response.getWriter().print("no");
}else{
response.getWriter().print("ok");
}
return searchDrugInjection(mapping,form,request,response);
}它就报红字的地方错了!帮帮忙!谢谢!
ActionForm form, HttpServletRequest request,
HttpServletResponse response)throws Exception{
int firstDrugno = Integer.parseInt(request.getParameter("firstDrugno"));
int secondDrugno = Integer.parseInt(request.getParameter("secondDrugno"));
//根据id查出相关信息
String hql = "from InjectionTabu i where i.firstDrug.id ="+firstDrugno+" and i.secondDrug.id = "+secondDrugno+"";
List list = drugInjectionTabuBiz.findByHql(hql);
if(list.size() != 0){
response.getWriter().print("no");
}else{
response.getWriter().print("ok");
}
return searchDrugInjection(mapping,form,request,response);
}它就报红字的地方错了!帮帮忙!谢谢!
解决方案 »
- 是爬虫里的代码怎么理解,刚开始学习
- jstl迭代标签问题
- jsp怎样实现,单击下拉菜单中值,在本页面显示相应内容?
- POI使用多模板问题
- java类文件中 ,如何删掉指定的文件,比如E:\\Tomcat 5.0\\webapps\\sms\\1.xls
- FTP实现实现多台机器的同步,在服务器上某文件夹,想将此文件夹的所有内容通过FTP Copy到另几台机器上
- 紧急求救
- javabean路径设置?
- 强烈建议开一个elicpse 开发jsp得专版
- 请问我在JSP中的同一个form表单里即有其他文本字段,又有上传的文件的输入框,怎么做?
- Fckeditor的问题,在线等。。。。。。。
- 如何解决向数据库中添加重复记录?
这次是错误的转型。
比如: Integer.parseInt("abc");就报这样的错。
你应该传一个数,要不就判断下。
int firstDrugno=0;
try{
firstDrugno= Integer.parseInt(request.getParameter("firstDrugno"));
}catch(Exception e){
firstDrugno=给个默认值
}
你输出一下request.getParameter("firstDrugno")
看看他得值
转换之前判断一下
String str = request.getParameter("firstDrugno");
int firstDrugno = 0;
if(str != null && !"".equals(str)) {
firstDrugno = Integer.parseInt(str);
}
{
try
{
int firstDrugno = Integer.parseInt(request.getParameter("firstDrugno"));
int secondDrugno = Integer.parseInt(request.getParameter("secondDrugno"));
//根据id查出相关信息 String hql = "from InjectionTabu i where i.firstDrug.id ="+firstDrugno+" and i.secondDrug.id = "+secondDrugno+"";
List list = drugInjectionTabuBiz.findByHql(hql);
if(list.size() != 0)
{
response.getWriter().print("no");
}
else
{
response.getWriter().print("ok");
}
}
catch (NumberFormatException e)
{
firstDrugno = xxxxxxxxxxx;
}
return searchDrugInjection(mapping,form,request,response);
}