为了账号安全,请及时绑定邮箱和手机立即绑定

onclick 触发一个事件跳转到servlet,当前servlet执行了两次

onclick 触发一个事件跳转到servlet,当前servlet执行了两次

qq_Paranoia_33688088 2016-09-09 15:04:36
<td><input type="button" value="查看学生信息" onclick="return dosubmit()" /></td> function dosubmit(){ var form = document.getElementById("form"); form.action="StudentResult"; return true; }package com.share.test;import java.io.IOException;import java.util.List;import java.util.Map;import java.util.concurrent.ConcurrentHashMap;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;@WebServlet("/StudentResult")public class StudentResult extends HttpServlet{ /** *  */ private static final long serialVersionUID = 1L; @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); HttpSession session = request.getSession(); Student student=new Student(); String str=""; session.setAttribute("sresult", str); request.getRequestDispatcher("/Studet.jsp").forward(request, response); }}
查看完整描述

1 回答

?
拖鞋_

TA贡献453条经验 获得超223个赞

把return删了试试

查看完整回答
反对 回复 2016-09-09
  • 1 回答
  • 0 关注
  • 7020 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信