猿问

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

<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);

}

}


qq_Paranoia_33688088
浏览 7021回答 1
1回答

拖鞋_

把return删了试试
随时随地看视频慕课网APP

相关分类

Java
我要回答