전달 페이지에 오류가 나는 앵커JSP :이 질문은 이전에 관련
<a href="#" id="Email">send email</a>
그것이 내가 요청을 처리
서블릿에서$("#Email").click(function() {
var option={
"action":"sendEmail"
};
$.getJSON('StudentManagementServlet',option, function(hasEmail) {
if(hasEmail == false){
// //view form to let user enter his email
$("#CommViaEmail").fadeIn("normal");
}
});
});
JSON을 사용하여 서블릿을 호출을 통해 클릭 할 때
if (action != null && action.equals("sendEmail")) {
//open connection to db
con.setAutoCommit(false);
String email = ParentManagement.getParentEmail(con, stdNo);
if (email != null) {
String commResult = createAccountAndSendEmail(con, parentNo, email);
request.setAttribute("result", commResult);
request.setAttribute("incp", "ResultPage");
RequestDispatcher dispatcher = request.getRequestDispatcher("/index.jsp");
dispatcher.forward(request, response); //doesn't make forward!!!!!
System.out.println(">>send email DONE!!");
con.commit();
return;
} else {
boolean hasEmail = false;
String json = new Gson().toJson(hasEmail);
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(json);
}
}
여기에 문제는 사용자가 이메일을 가지고 있다면 이메일을 보내지 만 결과 페이지로 전달하지 않기를 요청하는 것입니다. e, 심지어 print 문이 인쇄됩니다 "System.out.println (">> 보내기 전자 메일 보내기 !! ");" ??
@BalusC, 요청과 함께 전달할 속성이 많습니다. 어떻게 javascript를 사용하여 전달할 수 있습니까? – palAlaa
대신 요청 매개 변수로 전달할 수 있습니다. 결국, 왜 다른 페이지로 넘어가시겠습니까? 같은 페이지에서 바로 성공 메시지를 보여줄 필요가 없습니다. – BalusC
@BalusC, 선생님은 웹 응용 프로그램에서 다른 페이지에 표시된 결과를 한 번 말해 주셨습니다. – palAlaa