81,091
社区成员
发帖
与我相关
我的任务
分享
public class OrderDetailServlet extends HttpServlet {
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String orderId = request.getParameter("orderId");
String meauId = request.getParameter("meauId");
String num = request.getParameter("num");
String remark = request.getParameter("remark");
OrderDao dao = new OrderDaoImpl();
OrderDetail od = new OrderDetail();
od.setMenuId(Integer.parseInt(meauId));
od.setOrderId(Integer.parseInt(orderId));
od.setNum(Integer.parseInt(num));
od.setRemark(remark);
dao.saveOrderDetail(od);
out.print(remark);
out.flush();
out.close();
}
}
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<%@page import="com.action.*"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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" />
<title>菜品选择</title>
<style type="text/css">
body{
background-image:url(<%=path %>/img/banner.png);
display:block;
}
.tablebox{background-image:url(<%=path %>/img/bg_tm.png);font-size:15px;color:#304031}
.Add{text-align:right;margin-top:15px;margin-right:45px;}
.title{font-size:18px}
div{font-weight:bold}
</style>
<script type='text/javascript' src='<%=path %>/dwr/interface/loginService.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script language="javascript">
var i=0;
function caipuAll()
{
if(i==0)
{
document.getElementById("indicator").style.display="block";
loginService.caipuAll(callback);
i=1;
}
}
function callback(data)
{
document.getElementById("indicator").style.display="none";
DWRUtil.addOptions("meauId",data,"id","name");
}
function check()
{
if(document.formAdd.meauId.value==0)
{
alert("请选择类别");
return false;
}
return true;
}
</script>
</head>
<body>
<jsp:include page="/admin/daohang.jsp" flush="true"/>
<div class="tablebox">
<form action="<%=path %>/diancai" name="formAdd" method="post">
<table width="60%" align="center" border="0" cellpadding="0" cellspacing="0" style="margin:0 auto">
<tr height="40px">
<td colspan="7" align="center" class="title" ><span> 菜品选择</span></td>
</tr>
<tr align='center' height="30">
<td width="10%" align="right">
菜谱列表:
</td>
<td width="15%" align="left">
<table border="0">
<tr>
<td>
<select name="meauId" id="meauId" onclick="caipuAll()">
<option value="0">请选择菜品</option>
</select>
</td>
<td>
<img id="indicator" src="<%=path %>/img/loading.gif" style="display:none"/>
</td>
</tr>
</table>
</td>
<td width="8%"align="right">
数量:
</td>
<td width="15%" align="left">
<input type="text" name="num" size="20"/>
</td>
<td width="7%" align="right">
备注:
</td>
<td width="10%" align="left">
<input type="text" name="remark" size="20"/>
</td>
<td width="10%" align="left">
<input type="submit" value="提交" onclick="return check()"/>
</tr>
</table>
</form>
</div>
</body>
</html>
request.getContextPath()+"/admin/order/orderdish.jsp?orederId="+id;
然后在orderdish.jsp使用js得到这个id,
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
预先在orderdish.jsp的form表单写一个隐藏字段。。。。
<input id="oId" type="hidden" name="orderId"/>
调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
[/quote]
太感谢你了,这么细致的回答,我是新手,很多东西还是照葫芦画瓢,还想请问一下,最后一步调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
在哪条代码调用这个function?前面的都跟上了,这步有点没跟上~ 麻烦你了~[/quote]
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
window.onload=function(){
document.getElementById("隐藏标签id");
}
[/quote]
您看我orderdish.jsp整个这样写的,Debug之后,显示orderId还是传过去空值,是不是我按你的最后一步,没写对地方额;
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<%@page import="com.action.*"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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" />
<title>菜品选择</title>
<style type="text/css">
body{
background-image:url(<%=path %>/img/banner.png);
display:block;
}
.tablebox{background-image:url(<%=path %>/img/bg_tm.png);font-size:15px;color:#304031}
.Add{text-align:right;margin-top:15px;margin-right:45px;}
.title{font-size:18px}
div{font-weight:bold}
</style>
<script type='text/javascript' src='<%=path %>/dwr/interface/loginService.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script language="javascript">
var i=0;
function caipuAll()
{
if(i==0)
{
document.getElementById("indicator").style.display="block";
loginService.caipuAll(callback);
i=1;
}
}
function callback(data)
{
document.getElementById("indicator").style.display="none";
DWRUtil.addOptions("meauId",data,"id","name");
}
function check()
{
if(document.formAdd.meauId.value==0)
{
alert("请选择类别");
return false;
}
return true;
}
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]);
return null;
}
window.onload=function(){
document.getElementById("oId");
}
</script>
</head>
<body>
<jsp:include page="/admin/daohang.jsp" flush="true"/>
<div class="tablebox">
<form action="<%=path %>/diancai" name="formAdd" method="post">
<input id="oId" type="hidden" name="orderId" />
<table width="60%" align="center" border="0" cellpadding="0" cellspacing="0" style="margin:0 auto">
<tr height="40px">
<td colspan="7" align="center" class="title" ><span> 菜品选择</span></td>
</tr>
<tr align='center' height="30">
<td width="10%" align="right">
菜谱列表:
</td>
<td width="15%" align="left">
<table border="0">
<tr>
<td>
<select name="meauId" id="meauId" onclick="caipuAll()">
<option value="0">请选择菜品</option>
</select>
</td>
<td>
<img id="indicator" src="<%=path %>/img/loading.gif" style="display:none"/>
</td>
</tr>
</table>
</td>
<td width="8%"align="right">
数量:
</td>
<td width="15%" align="left">
<input type="text" name="num" size="20"/>
</td>
<td width="7%" align="right">
备注:
</td>
<td width="10%" align="left">
<input type="text" name="remark" size="20"/>
</td>
<td width="10%" align="left">
<input type="submit" value="提交" onclick="return check()"/>
</tr>
</table>
</form>
</div>
</body>
</html>
[/quote]
刚才没写完恢复了。。。。
window.onload=function(){
document.getElementById("oId").value=getUrlParams("orderId");
}
[/quote]
改成这样是这个异常java.lang.NumberFormatException: For input string: ""
java.lang.NumberFormatException.forInputString(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
com.action.OrderDetailServlet.service(OrderDetailServlet.java:39)
我刚刚贴的代码里这个window.onload代码写的位置对么?[/quote]
你拼接在链接后面是不是orderId????检查一下。。。。
?orderId=18和getUrlParams("orderId")是否一致。。。[/quote]
我在重定向里拼接的是orderId,,这是又调试过的链接http://localhost:8080/wjjlcy/admin/order/orderdish.jsp?orederId=21
getUrlParams("orderId")这个不知道怎么检查是不是和拼接的一致额[/quote]
response.sendRedirect(request.getContextPath()+"/admin/order/orderdish.jsp?orderId="+id);
和getUrlParams("orderId")......这两个要保持一致,刚才这个orederId=21多了一个e了[/quote]
你真的太厉害了,解决了,页面跳转了,真是太厉害了,能加你一个联系方式么?
request.getContextPath()+"/admin/order/orderdish.jsp?orederId="+id;
然后在orderdish.jsp使用js得到这个id,
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
预先在orderdish.jsp的form表单写一个隐藏字段。。。。
<input id="oId" type="hidden" name="orderId"/>
调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
[/quote]
太感谢你了,这么细致的回答,我是新手,很多东西还是照葫芦画瓢,还想请问一下,最后一步调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
在哪条代码调用这个function?前面的都跟上了,这步有点没跟上~ 麻烦你了~[/quote]
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
window.onload=function(){
document.getElementById("隐藏标签id");
}
[/quote]
您看我orderdish.jsp整个这样写的,Debug之后,显示orderId还是传过去空值,是不是我按你的最后一步,没写对地方额;
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<%@page import="com.action.*"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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" />
<title>菜品选择</title>
<style type="text/css">
body{
background-image:url(<%=path %>/img/banner.png);
display:block;
}
.tablebox{background-image:url(<%=path %>/img/bg_tm.png);font-size:15px;color:#304031}
.Add{text-align:right;margin-top:15px;margin-right:45px;}
.title{font-size:18px}
div{font-weight:bold}
</style>
<script type='text/javascript' src='<%=path %>/dwr/interface/loginService.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script language="javascript">
var i=0;
function caipuAll()
{
if(i==0)
{
document.getElementById("indicator").style.display="block";
loginService.caipuAll(callback);
i=1;
}
}
function callback(data)
{
document.getElementById("indicator").style.display="none";
DWRUtil.addOptions("meauId",data,"id","name");
}
function check()
{
if(document.formAdd.meauId.value==0)
{
alert("请选择类别");
return false;
}
return true;
}
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]);
return null;
}
window.onload=function(){
document.getElementById("oId");
}
</script>
</head>
<body>
<jsp:include page="/admin/daohang.jsp" flush="true"/>
<div class="tablebox">
<form action="<%=path %>/diancai" name="formAdd" method="post">
<input id="oId" type="hidden" name="orderId" />
<table width="60%" align="center" border="0" cellpadding="0" cellspacing="0" style="margin:0 auto">
<tr height="40px">
<td colspan="7" align="center" class="title" ><span> 菜品选择</span></td>
</tr>
<tr align='center' height="30">
<td width="10%" align="right">
菜谱列表:
</td>
<td width="15%" align="left">
<table border="0">
<tr>
<td>
<select name="meauId" id="meauId" onclick="caipuAll()">
<option value="0">请选择菜品</option>
</select>
</td>
<td>
<img id="indicator" src="<%=path %>/img/loading.gif" style="display:none"/>
</td>
</tr>
</table>
</td>
<td width="8%"align="right">
数量:
</td>
<td width="15%" align="left">
<input type="text" name="num" size="20"/>
</td>
<td width="7%" align="right">
备注:
</td>
<td width="10%" align="left">
<input type="text" name="remark" size="20"/>
</td>
<td width="10%" align="left">
<input type="submit" value="提交" onclick="return check()"/>
</tr>
</table>
</form>
</div>
</body>
</html>
[/quote]
刚才没写完恢复了。。。。
window.onload=function(){
document.getElementById("oId").value=getUrlParams("orderId");
}
[/quote]
改成这样是这个异常java.lang.NumberFormatException: For input string: ""
java.lang.NumberFormatException.forInputString(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
com.action.OrderDetailServlet.service(OrderDetailServlet.java:39)
我刚刚贴的代码里这个window.onload代码写的位置对么?[/quote]
你拼接在链接后面是不是orderId????检查一下。。。。
?orderId=18和getUrlParams("orderId")是否一致。。。[/quote]
我在重定向里拼接的是orderId,,这是又调试过的链接http://localhost:8080/wjjlcy/admin/order/orderdish.jsp?orederId=21
getUrlParams("orderId")这个不知道怎么检查是不是和拼接的一致额[/quote]
response.sendRedirect(request.getContextPath()+"/admin/order/orderdish.jsp?orderId="+id);
和getUrlParams("orderId")......这两个要保持一致,刚才这个orederId=21多了一个e了
request.getContextPath()+"/admin/order/orderdish.jsp?orederId="+id;
然后在orderdish.jsp使用js得到这个id,
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
预先在orderdish.jsp的form表单写一个隐藏字段。。。。
<input id="oId" type="hidden" name="orderId"/>
调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
[/quote]
太感谢你了,这么细致的回答,我是新手,很多东西还是照葫芦画瓢,还想请问一下,最后一步调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
在哪条代码调用这个function?前面的都跟上了,这步有点没跟上~ 麻烦你了~[/quote]
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
window.onload=function(){
document.getElementById("隐藏标签id");
}
[/quote]
您看我orderdish.jsp整个这样写的,Debug之后,显示orderId还是传过去空值,是不是我按你的最后一步,没写对地方额;
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<%@page import="com.action.*"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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" />
<title>菜品选择</title>
<style type="text/css">
body{
background-image:url(<%=path %>/img/banner.png);
display:block;
}
.tablebox{background-image:url(<%=path %>/img/bg_tm.png);font-size:15px;color:#304031}
.Add{text-align:right;margin-top:15px;margin-right:45px;}
.title{font-size:18px}
div{font-weight:bold}
</style>
<script type='text/javascript' src='<%=path %>/dwr/interface/loginService.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script language="javascript">
var i=0;
function caipuAll()
{
if(i==0)
{
document.getElementById("indicator").style.display="block";
loginService.caipuAll(callback);
i=1;
}
}
function callback(data)
{
document.getElementById("indicator").style.display="none";
DWRUtil.addOptions("meauId",data,"id","name");
}
function check()
{
if(document.formAdd.meauId.value==0)
{
alert("请选择类别");
return false;
}
return true;
}
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]);
return null;
}
window.onload=function(){
document.getElementById("oId");
}
</script>
</head>
<body>
<jsp:include page="/admin/daohang.jsp" flush="true"/>
<div class="tablebox">
<form action="<%=path %>/diancai" name="formAdd" method="post">
<input id="oId" type="hidden" name="orderId" />
<table width="60%" align="center" border="0" cellpadding="0" cellspacing="0" style="margin:0 auto">
<tr height="40px">
<td colspan="7" align="center" class="title" ><span> 菜品选择</span></td>
</tr>
<tr align='center' height="30">
<td width="10%" align="right">
菜谱列表:
</td>
<td width="15%" align="left">
<table border="0">
<tr>
<td>
<select name="meauId" id="meauId" onclick="caipuAll()">
<option value="0">请选择菜品</option>
</select>
</td>
<td>
<img id="indicator" src="<%=path %>/img/loading.gif" style="display:none"/>
</td>
</tr>
</table>
</td>
<td width="8%"align="right">
数量:
</td>
<td width="15%" align="left">
<input type="text" name="num" size="20"/>
</td>
<td width="7%" align="right">
备注:
</td>
<td width="10%" align="left">
<input type="text" name="remark" size="20"/>
</td>
<td width="10%" align="left">
<input type="submit" value="提交" onclick="return check()"/>
</tr>
</table>
</form>
</div>
</body>
</html>
[/quote]
刚才没写完恢复了。。。。
window.onload=function(){
document.getElementById("oId").value=getUrlParams("orderId");
}
[/quote]
改成这样是这个异常java.lang.NumberFormatException: For input string: ""
java.lang.NumberFormatException.forInputString(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
com.action.OrderDetailServlet.service(OrderDetailServlet.java:39)
我刚刚贴的代码里这个window.onload代码写的位置对么?[/quote]
你拼接在链接后面是不是orderId????检查一下。。。。
?orderId=18和getUrlParams("orderId")是否一致。。。[/quote]
我在重定向里拼接的是orderId,,这是又调试过的链接http://localhost:8080/wjjlcy/admin/order/orderdish.jsp?orederId=21
getUrlParams("orderId")这个不知道怎么检查是不是和拼接的一致额
request.getContextPath()+"/admin/order/orderdish.jsp?orederId="+id;
然后在orderdish.jsp使用js得到这个id,
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
预先在orderdish.jsp的form表单写一个隐藏字段。。。。
<input id="oId" type="hidden" name="orderId"/>
调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
[/quote]
太感谢你了,这么细致的回答,我是新手,很多东西还是照葫芦画瓢,还想请问一下,最后一步调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
在哪条代码调用这个function?前面的都跟上了,这步有点没跟上~ 麻烦你了~[/quote]
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
window.onload=function(){
document.getElementById("隐藏标签id");
}
[/quote]
您看我orderdish.jsp整个这样写的,Debug之后,显示orderId还是传过去空值,是不是我按你的最后一步,没写对地方额;
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<%@page import="com.action.*"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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" />
<title>菜品选择</title>
<style type="text/css">
body{
background-image:url(<%=path %>/img/banner.png);
display:block;
}
.tablebox{background-image:url(<%=path %>/img/bg_tm.png);font-size:15px;color:#304031}
.Add{text-align:right;margin-top:15px;margin-right:45px;}
.title{font-size:18px}
div{font-weight:bold}
</style>
<script type='text/javascript' src='<%=path %>/dwr/interface/loginService.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script language="javascript">
var i=0;
function caipuAll()
{
if(i==0)
{
document.getElementById("indicator").style.display="block";
loginService.caipuAll(callback);
i=1;
}
}
function callback(data)
{
document.getElementById("indicator").style.display="none";
DWRUtil.addOptions("meauId",data,"id","name");
}
function check()
{
if(document.formAdd.meauId.value==0)
{
alert("请选择类别");
return false;
}
return true;
}
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]);
return null;
}
window.onload=function(){
document.getElementById("oId");
}
</script>
</head>
<body>
<jsp:include page="/admin/daohang.jsp" flush="true"/>
<div class="tablebox">
<form action="<%=path %>/diancai" name="formAdd" method="post">
<input id="oId" type="hidden" name="orderId" />
<table width="60%" align="center" border="0" cellpadding="0" cellspacing="0" style="margin:0 auto">
<tr height="40px">
<td colspan="7" align="center" class="title" ><span> 菜品选择</span></td>
</tr>
<tr align='center' height="30">
<td width="10%" align="right">
菜谱列表:
</td>
<td width="15%" align="left">
<table border="0">
<tr>
<td>
<select name="meauId" id="meauId" onclick="caipuAll()">
<option value="0">请选择菜品</option>
</select>
</td>
<td>
<img id="indicator" src="<%=path %>/img/loading.gif" style="display:none"/>
</td>
</tr>
</table>
</td>
<td width="8%"align="right">
数量:
</td>
<td width="15%" align="left">
<input type="text" name="num" size="20"/>
</td>
<td width="7%" align="right">
备注:
</td>
<td width="10%" align="left">
<input type="text" name="remark" size="20"/>
</td>
<td width="10%" align="left">
<input type="submit" value="提交" onclick="return check()"/>
</tr>
</table>
</form>
</div>
</body>
</html>
[/quote]
刚才没写完恢复了。。。。
window.onload=function(){
document.getElementById("oId").value=getUrlParams("orderId");
}
[/quote]
改成这样是这个异常java.lang.NumberFormatException: For input string: ""
java.lang.NumberFormatException.forInputString(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
com.action.OrderDetailServlet.service(OrderDetailServlet.java:39)
我刚刚贴的代码里这个window.onload代码写的位置对么?[/quote]
你拼接在链接后面是不是orderId????检查一下。。。。
?orderId=18和getUrlParams("orderId")是否一致。。。
request.getContextPath()+"/admin/order/orderdish.jsp?orederId="+id;
然后在orderdish.jsp使用js得到这个id,
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
预先在orderdish.jsp的form表单写一个隐藏字段。。。。
<input id="oId" type="hidden" name="orderId"/>
调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
[/quote]
太感谢你了,这么细致的回答,我是新手,很多东西还是照葫芦画瓢,还想请问一下,最后一步调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
在哪条代码调用这个function?前面的都跟上了,这步有点没跟上~ 麻烦你了~[/quote]
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
window.onload=function(){
document.getElementById("隐藏标签id");
}
[/quote]
您看我orderdish.jsp整个这样写的,Debug之后,显示orderId还是传过去空值,是不是我按你的最后一步,没写对地方额;
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<%@page import="com.action.*"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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" />
<title>菜品选择</title>
<style type="text/css">
body{
background-image:url(<%=path %>/img/banner.png);
display:block;
}
.tablebox{background-image:url(<%=path %>/img/bg_tm.png);font-size:15px;color:#304031}
.Add{text-align:right;margin-top:15px;margin-right:45px;}
.title{font-size:18px}
div{font-weight:bold}
</style>
<script type='text/javascript' src='<%=path %>/dwr/interface/loginService.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script language="javascript">
var i=0;
function caipuAll()
{
if(i==0)
{
document.getElementById("indicator").style.display="block";
loginService.caipuAll(callback);
i=1;
}
}
function callback(data)
{
document.getElementById("indicator").style.display="none";
DWRUtil.addOptions("meauId",data,"id","name");
}
function check()
{
if(document.formAdd.meauId.value==0)
{
alert("请选择类别");
return false;
}
return true;
}
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]);
return null;
}
window.onload=function(){
document.getElementById("oId");
}
</script>
</head>
<body>
<jsp:include page="/admin/daohang.jsp" flush="true"/>
<div class="tablebox">
<form action="<%=path %>/diancai" name="formAdd" method="post">
<input id="oId" type="hidden" name="orderId" />
<table width="60%" align="center" border="0" cellpadding="0" cellspacing="0" style="margin:0 auto">
<tr height="40px">
<td colspan="7" align="center" class="title" ><span> 菜品选择</span></td>
</tr>
<tr align='center' height="30">
<td width="10%" align="right">
菜谱列表:
</td>
<td width="15%" align="left">
<table border="0">
<tr>
<td>
<select name="meauId" id="meauId" onclick="caipuAll()">
<option value="0">请选择菜品</option>
</select>
</td>
<td>
<img id="indicator" src="<%=path %>/img/loading.gif" style="display:none"/>
</td>
</tr>
</table>
</td>
<td width="8%"align="right">
数量:
</td>
<td width="15%" align="left">
<input type="text" name="num" size="20"/>
</td>
<td width="7%" align="right">
备注:
</td>
<td width="10%" align="left">
<input type="text" name="remark" size="20"/>
</td>
<td width="10%" align="left">
<input type="submit" value="提交" onclick="return check()"/>
</tr>
</table>
</form>
</div>
</body>
</html>
[/quote]
刚才没写完恢复了。。。。
window.onload=function(){
document.getElementById("oId").value=getUrlParams("orderId");
}
[/quote]
改成这样是这个异常java.lang.NumberFormatException: For input string: ""
java.lang.NumberFormatException.forInputString(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
com.action.OrderDetailServlet.service(OrderDetailServlet.java:39)
我刚刚贴的代码里这个window.onload代码写的位置对么?
request.getContextPath()+"/admin/order/orderdish.jsp?orederId="+id;
然后在orderdish.jsp使用js得到这个id,
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
预先在orderdish.jsp的form表单写一个隐藏字段。。。。
<input id="oId" type="hidden" name="orderId"/>
调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
[/quote]
太感谢你了,这么细致的回答,我是新手,很多东西还是照葫芦画瓢,还想请问一下,最后一步调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
在哪条代码调用这个function?前面的都跟上了,这步有点没跟上~ 麻烦你了~[/quote]
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
window.onload=function(){
document.getElementById("隐藏标签id");
}
[/quote]
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
window.onload=function(){
var orderId=getUrlParams("orderId");
document.getElementById("隐藏标签id").value=orderId;
}
[/quote]
跳转提交后,地址显示http://localhost:8080/wjjlcy/admin/order/orderdish.jsp?orederId=18 有orderId。
异常提示是java.lang.NumberFormatException: For input string: ""
java.lang.NumberFormatException.forInputString(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
com.action.OrderDetailServlet.service(OrderDetailServlet.java:39)[/quote]
刚才这个拼写错饿了。。。拼写要对得上,拼在url后面orderId=18,就这样调用getUrlParams(“orderId”)...
可以先alert看一下值对不对。。。。
request.getContextPath()+"/admin/order/orderdish.jsp?orederId="+id;
然后在orderdish.jsp使用js得到这个id,
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
预先在orderdish.jsp的form表单写一个隐藏字段。。。。
<input id="oId" type="hidden" name="orderId"/>
调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
[/quote]
太感谢你了,这么细致的回答,我是新手,很多东西还是照葫芦画瓢,还想请问一下,最后一步调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
在哪条代码调用这个function?前面的都跟上了,这步有点没跟上~ 麻烦你了~[/quote]
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
window.onload=function(){
document.getElementById("隐藏标签id");
}
[/quote]
您看我orderdish.jsp整个这样写的,Debug之后,显示orderId还是传过去空值,是不是我按你的最后一步,没写对地方额;
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<%@page import="com.action.*"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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" />
<title>菜品选择</title>
<style type="text/css">
body{
background-image:url(<%=path %>/img/banner.png);
display:block;
}
.tablebox{background-image:url(<%=path %>/img/bg_tm.png);font-size:15px;color:#304031}
.Add{text-align:right;margin-top:15px;margin-right:45px;}
.title{font-size:18px}
div{font-weight:bold}
</style>
<script type='text/javascript' src='<%=path %>/dwr/interface/loginService.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script language="javascript">
var i=0;
function caipuAll()
{
if(i==0)
{
document.getElementById("indicator").style.display="block";
loginService.caipuAll(callback);
i=1;
}
}
function callback(data)
{
document.getElementById("indicator").style.display="none";
DWRUtil.addOptions("meauId",data,"id","name");
}
function check()
{
if(document.formAdd.meauId.value==0)
{
alert("请选择类别");
return false;
}
return true;
}
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]);
return null;
}
window.onload=function(){
document.getElementById("oId");
}
</script>
</head>
<body>
<jsp:include page="/admin/daohang.jsp" flush="true"/>
<div class="tablebox">
<form action="<%=path %>/diancai" name="formAdd" method="post">
<input id="oId" type="hidden" name="orderId" />
<table width="60%" align="center" border="0" cellpadding="0" cellspacing="0" style="margin:0 auto">
<tr height="40px">
<td colspan="7" align="center" class="title" ><span> 菜品选择</span></td>
</tr>
<tr align='center' height="30">
<td width="10%" align="right">
菜谱列表:
</td>
<td width="15%" align="left">
<table border="0">
<tr>
<td>
<select name="meauId" id="meauId" onclick="caipuAll()">
<option value="0">请选择菜品</option>
</select>
</td>
<td>
<img id="indicator" src="<%=path %>/img/loading.gif" style="display:none"/>
</td>
</tr>
</table>
</td>
<td width="8%"align="right">
数量:
</td>
<td width="15%" align="left">
<input type="text" name="num" size="20"/>
</td>
<td width="7%" align="right">
备注:
</td>
<td width="10%" align="left">
<input type="text" name="remark" size="20"/>
</td>
<td width="10%" align="left">
<input type="submit" value="提交" onclick="return check()"/>
</tr>
</table>
</form>
</div>
</body>
</html>
[/quote]
刚才没写完恢复了。。。。
window.onload=function(){
document.getElementById("oId").value=getUrlParams("orderId");
}
request.getContextPath()+"/admin/order/orderdish.jsp?orederId="+id;
然后在orderdish.jsp使用js得到这个id,
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
预先在orderdish.jsp的form表单写一个隐藏字段。。。。
<input id="oId" type="hidden" name="orderId"/>
调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
[/quote]
太感谢你了,这么细致的回答,我是新手,很多东西还是照葫芦画瓢,还想请问一下,最后一步调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
在哪条代码调用这个function?前面的都跟上了,这步有点没跟上~ 麻烦你了~[/quote]
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
window.onload=function(){
document.getElementById("隐藏标签id");
}
[/quote]
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
window.onload=function(){
var orderId=getUrlParams("orderId");
document.getElementById("隐藏标签id").value=orderId;
}
[/quote]
跳转提交后,地址显示http://localhost:8080/wjjlcy/admin/order/orderdish.jsp?orederId=18 有orderId。
异常提示是java.lang.NumberFormatException: For input string: ""
java.lang.NumberFormatException.forInputString(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
com.action.OrderDetailServlet.service(OrderDetailServlet.java:39)
request.getContextPath()+"/admin/order/orderdish.jsp?orederId="+id;
然后在orderdish.jsp使用js得到这个id,
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
预先在orderdish.jsp的form表单写一个隐藏字段。。。。
<input id="oId" type="hidden" name="orderId"/>
调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
[/quote]
太感谢你了,这么细致的回答,我是新手,很多东西还是照葫芦画瓢,还想请问一下,最后一步调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
在哪条代码调用这个function?前面的都跟上了,这步有点没跟上~ 麻烦你了~[/quote]
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
window.onload=function(){
document.getElementById("隐藏标签id");
}
[/quote]
您看我orderdish.jsp整个这样写的,Debug之后,显示orderId还是传过去空值,是不是我按你的最后一步,没写对地方额;
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<%@page import="com.action.*"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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" />
<title>菜品选择</title>
<style type="text/css">
body{
background-image:url(<%=path %>/img/banner.png);
display:block;
}
.tablebox{background-image:url(<%=path %>/img/bg_tm.png);font-size:15px;color:#304031}
.Add{text-align:right;margin-top:15px;margin-right:45px;}
.title{font-size:18px}
div{font-weight:bold}
</style>
<script type='text/javascript' src='<%=path %>/dwr/interface/loginService.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script language="javascript">
var i=0;
function caipuAll()
{
if(i==0)
{
document.getElementById("indicator").style.display="block";
loginService.caipuAll(callback);
i=1;
}
}
function callback(data)
{
document.getElementById("indicator").style.display="none";
DWRUtil.addOptions("meauId",data,"id","name");
}
function check()
{
if(document.formAdd.meauId.value==0)
{
alert("请选择类别");
return false;
}
return true;
}
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]);
return null;
}
window.onload=function(){
document.getElementById("oId");
}
</script>
</head>
<body>
<jsp:include page="/admin/daohang.jsp" flush="true"/>
<div class="tablebox">
<form action="<%=path %>/diancai" name="formAdd" method="post">
<input id="oId" type="hidden" name="orderId" />
<table width="60%" align="center" border="0" cellpadding="0" cellspacing="0" style="margin:0 auto">
<tr height="40px">
<td colspan="7" align="center" class="title" ><span> 菜品选择</span></td>
</tr>
<tr align='center' height="30">
<td width="10%" align="right">
菜谱列表:
</td>
<td width="15%" align="left">
<table border="0">
<tr>
<td>
<select name="meauId" id="meauId" onclick="caipuAll()">
<option value="0">请选择菜品</option>
</select>
</td>
<td>
<img id="indicator" src="<%=path %>/img/loading.gif" style="display:none"/>
</td>
</tr>
</table>
</td>
<td width="8%"align="right">
数量:
</td>
<td width="15%" align="left">
<input type="text" name="num" size="20"/>
</td>
<td width="7%" align="right">
备注:
</td>
<td width="10%" align="left">
<input type="text" name="remark" size="20"/>
</td>
<td width="10%" align="left">
<input type="submit" value="提交" onclick="return check()"/>
</tr>
</table>
</form>
</div>
</body>
</html>
request.getContextPath()+"/admin/order/orderdish.jsp?orederId="+id;
然后在orderdish.jsp使用js得到这个id,
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
预先在orderdish.jsp的form表单写一个隐藏字段。。。。
<input id="oId" type="hidden" name="orderId"/>
调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
[/quote]
太感谢你了,这么细致的回答,我是新手,很多东西还是照葫芦画瓢,还想请问一下,最后一步调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
在哪条代码调用这个function?前面的都跟上了,这步有点没跟上~ 麻烦你了~[/quote]
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
window.onload=function(){
document.getElementById("隐藏标签id");
}
[/quote]
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
window.onload=function(){
var orderId=getUrlParams("orderId");
document.getElementById("隐藏标签id").value=orderId;
}
request.getContextPath()+"/admin/order/orderdish.jsp?orederId="+id;
然后在orderdish.jsp使用js得到这个id,
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
预先在orderdish.jsp的form表单写一个隐藏字段。。。。
<input id="oId" type="hidden" name="orderId"/>
调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
[/quote]
太感谢你了,这么细致的回答,我是新手,很多东西还是照葫芦画瓢,还想请问一下,最后一步调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
在哪条代码调用这个function?前面的都跟上了,这步有点没跟上~ 麻烦你了~[/quote]
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
window.onload=function(){
document.getElementById("隐藏标签id");
}
request.getContextPath()+"/admin/order/orderdish.jsp?orederId="+id;
然后在orderdish.jsp使用js得到这个id,
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
预先在orderdish.jsp的form表单写一个隐藏字段。。。。
<input id="oId" type="hidden" name="orderId"/>
调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
[/quote]
太感谢你了,这么细致的回答,我是新手,很多东西还是照葫芦画瓢,还想请问一下,最后一步调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
在哪条代码调用这个function?前面的都跟上了,这步有点没跟上~ 麻烦你了~
request.getContextPath()+"/admin/order/orderdish.jsp?orederId="+id;
然后在orderdish.jsp使用js得到这个id,
function getUrlParams(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
预先在orderdish.jsp的form表单写一个隐藏字段。。。。
<input id="oId" type="hidden" name="orderId"/>
调用function,getUrlParams("orderId")后得到orderId,给这个隐藏字段赋值,让它一起随表单提交就可以了。。。
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<jsp:directive.page import="java.text.SimpleDateFormat"/>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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" />
<title>开桌</title>
<style type="text/css">
body{
background-image:url(<%=path %>/img/banner.png);
display:block;
}
.tablebox{background-image:url(<%=path %>/img/bg_tm.png);font-size:15px;color:#304031}
.title{font-size:18px;font-weight:bold;}
div{font-weight:bold}
</style>
<script type='text/javascript' src='<%=path %>/dwr/interface/loginService.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script language="javascript">
</script>
</head>
<body>
<jsp:include page="/admin/daohang.jsp" flush="true"/>
<div class="tablebox">
<form action="<%=path %>/kaizhuo" name="formAdd" method="post">
<table width="100%" border="0" class="title" bordercolor="#668868" ;cellpadding="0" cellspacing="0" align="center" >
<tr height="40px">
<td colspan="3" align="center" class="title" ><span> 开桌</span></td>
</tr>
</table>
<table width="25%" align="center" border="0" cellpadding="0" cellspacing="0" style="margin:0 auto">
<tr align='center' height="30">
<td width="25%" align="right">
开桌时间:
</td>
<td width="45%" align="left">
<input type="text" name="orderTime" size="20" value="<%=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()) %>"/>
</td>
</tr>
<tr align='center' height="30">
<td width="25%" align="right">
桌号 :
</td>
<td width="45%" align="left">
<input type="text" name="tableId" size="20"/>
</td>
</tr>
<tr align='center' height="30">
<td width="25%" align="right">
人数 :
</td>
<td width="45%" align="left">
<input type="text" name="personNum" size="20" />
</td>
</tr>
<tr align='center' height="40">
<td width="25%" align="right">
</td>
<td width="45%" align="left">
<input type="submit" value="提交"/>
<input type="reset" value="重置"/>
</td>
</tr>
</table>
</form>
</body>
</html>
StartTableServlet.java代码
public class StartTableServlet extends HttpServlet {
// 构造方法
public StartTableServlet() {
super();
}
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter(); //输出
// 发送给浏览器
// 点餐时间
String orderTime = request.getParameter("orderTime");
// 桌号
String tableId = request.getParameter("tableId");
// 人数
String personNum = request.getParameter("personNum");
// 获得DAO接口
OrderDao dao = new OrderDaoImpl();
// 实例化订单类
Order o = new Order();
// 设置订单属性
o.setOrderTime(orderTime);
o.setPersonNum(Integer.parseInt(personNum));
o.setTableId(Integer.parseInt(tableId));
// 返回订单ID
int id = dao.saveOrder(o);
// 更新餐桌状态为 有人
dao.updateTableStatus(Integer.parseInt(tableId));
// 返回ID
response.sendRedirect(request.getContextPath()+"/admin/order/orderdish.jsp");
out.print(id);
out.flush();
out.close();
}
}
在web.xml中
<servlet>
<servlet-name>kaizhuo</servlet-name>
<servlet-class>com.action.StartTableServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>kaizhuo</servlet-name>
<url-pattern>/kaizhuo</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>diancai</servlet-name>
<servlet-class>com.action.OrderDetailServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>diancai</servlet-name>
<url-pattern>/diancai</url-pattern>
</servlet-mapping>
这两个页面之间数据的传递有点没写明白,求大神帮忙看看,为什么出现标题中的异常~~~