Spring MVC 从jsp页面传值到Controller方法里
我的后台代码@RequestMapping("/query")publicStringqueryByOrderId(HttpServletRequestrequest,@...
我的后台代码
@RequestMapping("/query")
public String queryByOrderId(HttpServletRequest request,@RequestParam(value="orderId",required=false) Long orderId , Model model) throws ParseException{
DataOrder order = biz.getById(orderId);
String points = "该订单不存在!";
if(order == null){
request.setAttribute("points", points);
}else{
List<DataOrder> listDataOrder = biz.queryorderByOrderId(orderId);
model.addAttribute("listDataOrder", listDataOrder);
}
return ACTION + "listOrders.jsp" ;
}
前台
<strong>订单号:</strong>
<input type="submitQuery" id="queryTxt" name="orderId"/>
<a href="<%=basePath%>dataOrder/queryorder.do?orderId=${orderId}">搜索</a>
报错信息
org.springframework.jdbc.UncategorizedSQLException: Error setting null parameter. Most JDBC drivers require that the JdbcType must be specified for all nullable parameters. Cause: java.sql.SQLException: 无效的列类型
; uncategorized SQLException for SQL []; SQL state [null]; error code [17004]; 无效的列类型; nested exception is java.sql.SQLException: 无效的列类型
说是orderId为空,应该怎么改,求教 展开
@RequestMapping("/query")
public String queryByOrderId(HttpServletRequest request,@RequestParam(value="orderId",required=false) Long orderId , Model model) throws ParseException{
DataOrder order = biz.getById(orderId);
String points = "该订单不存在!";
if(order == null){
request.setAttribute("points", points);
}else{
List<DataOrder> listDataOrder = biz.queryorderByOrderId(orderId);
model.addAttribute("listDataOrder", listDataOrder);
}
return ACTION + "listOrders.jsp" ;
}
前台
<strong>订单号:</strong>
<input type="submitQuery" id="queryTxt" name="orderId"/>
<a href="<%=basePath%>dataOrder/queryorder.do?orderId=${orderId}">搜索</a>
报错信息
org.springframework.jdbc.UncategorizedSQLException: Error setting null parameter. Most JDBC drivers require that the JdbcType must be specified for all nullable parameters. Cause: java.sql.SQLException: 无效的列类型
; uncategorized SQLException for SQL []; SQL state [null]; error code [17004]; 无效的列类型; nested exception is java.sql.SQLException: 无效的列类型
说是orderId为空,应该怎么改,求教 展开
展开全部
${orderId} 这个没取到标签的值吧,建议用按钮<button onclick="fuc()">
再写个
fuc(){
var vv = document.getElementById("queryTxt").value;
window.open("<%=basePath%>dataOrder/queryorder.do?orderId="+vv) ;
}
这样就可以了
追问
你说的我试过了,值是可以取到了,window.open是打开新的页面,我就想在原有的页面显示结果,应该怎么弄
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询