button调用servlet ,页面发生了跳转,但是没有执行servlet中doPost()方法?求教!
<Scripttype="text/javascript">functionSubmit(){window.location="/UserLogin/servlet/su...
<Script type="text/javascript">
function Submit(){
window.location="/UserLogin/servlet/success";
}
</Script>
<input type="button" name="seek" value="查询功能" id="seek" onclick="Submit()"/>
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String seek=(String)request.getParameter("seek");
String alter=(String)request.getParameter("alter");
if(seek!=null||alter!=null){
if(seek=="seek" && alter==null){
request.getRequestDispatcher("/seek.jsp").forward(request,response);
}
if(alter=="alter" && seek==null){
request.getRequestDispatcher("/alter.jsp").forward(request,response);
}
}else{
request.getRequestDispatcher("/success.jsp").forward(request,response);
}
} 展开
function Submit(){
window.location="/UserLogin/servlet/success";
}
</Script>
<input type="button" name="seek" value="查询功能" id="seek" onclick="Submit()"/>
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String seek=(String)request.getParameter("seek");
String alter=(String)request.getParameter("alter");
if(seek!=null||alter!=null){
if(seek=="seek" && alter==null){
request.getRequestDispatcher("/seek.jsp").forward(request,response);
}
if(alter=="alter" && seek==null){
request.getRequestDispatcher("/alter.jsp").forward(request,response);
}
}else{
request.getRequestDispatcher("/success.jsp").forward(request,response);
}
} 展开
2个回答
展开全部
应该是执行了doget
window.location="/UserLogin/servlet/success";//这句话会执行doget,并且传递不了参数。严格来说应该是
window.location.href="";
要加个form表单,
<Script type="text/javascript">
function Submit(){
document.form1.submit();
}
</Script>
<form action="/UserLogin/servlet/success" method="post" name="form1">
<input type="button" name="seek" value="查询功能" id="seek" onclick="Submit()"/>
</form>
window.location="/UserLogin/servlet/success";//这句话会执行doget,并且传递不了参数。严格来说应该是
window.location.href="";
要加个form表单,
<Script type="text/javascript">
function Submit(){
document.form1.submit();
}
</Script>
<form action="/UserLogin/servlet/success" method="post" name="form1">
<input type="button" name="seek" value="查询功能" id="seek" onclick="Submit()"/>
</form>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询