[java] controller에서 jsp로 값을 보내지 못함

2022. 12. 11. 22:46·🚀 from error to study/Java

 

 

 

jsp에서 Controller로 보낼 때는 모달창에 정보를 때려넣고 submit으로 보낸 상태

<sciprt>
	$("#reportSubmitButton").on("click", function() {
    
    	document.getElementById("report-form").submit();

    });
</script>

 

이렇게 return <script> 구문으로도 가능함!

    @ResponseBody
    @RequestMapping(value="reportComment.co", produces="text/html; charset=UTF-8")
    public String reportComment(String reportReason, String form_loginUserNo, @RequestParam(value="contentsId", defaultValue="1427") int contentsId, String form_commentUserNo, String form_reviewNo, Model model) {
    	
    	// System.out.println("reportReason: " + reportReason);
    	// System.out.println("loginUserNo: " + form_loginUserNo);
    	// System.out.println("contentsId:" + contentsId);
    	// System.out.println("commentUserNo: " + form_commentUserNo);
    	// System.out.println("reviewNo: " + form_reviewNo);
    	
    	String contentId = Integer.toString(contentsId);
    	
    	HashMap<String, String> map = new HashMap<>();
    	map.put("reportReason", reportReason);
    	map.put("form_loginUserNo", form_loginUserNo);
    	map.put("contentId", contentId);
    	map.put("form_commentUserNo", form_commentUserNo);
    	map.put("form_reviewNo", form_reviewNo);

    	int resultNum = reviewService.reportComment(map);
    	
    	if(resultNum > 0) {
	    	
	    	return "<script>"
	    		 + "alert('성공적으로 신고 접수되었습니다.');"
	    		 + "location.href='commentList.co';"
	    		 + "</script>";
	    	
    	} else {
    		
    		return "<script>"
   	    		 + "alert('신고 접수에 실패하였습니다. 잠시 후 다시 시도해 주세요.');"
   	    		 + "location.href='commentList.co';"
   	    		 + "</script>";
    		
    	}
    }

 

저작자표시 비영리 변경금지 (새창열림)
'🚀 from error to study/Java' 카테고리의 다른 글
  • [Bootstrap] 부트스트랩 모달 열었을 때 커서 깜빡임 속성 [= focus()] 주기
  • java.lang.ClassCastException: java.util.ArrayList cannot be cast to VO 객체 경로
  • [Spring] Error - The method get/set필드명() is undefined for the type VO클래스
  • [Spring] WARN : org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver - Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter for [class java.lang.Integer] with preset Content-Type 'null']
천재강쥐
천재강쥐
  • 천재강쥐
    디버거도 버거다
    천재강쥐
  • 전체
    오늘
    어제
    • Category (467)
      • 진짜 너무 궁금한데 이걸 나만 몰라...? (0)
      • 💾 Portfolio (2)
      • 🐤 CodingTest (28)
        • Java (20)
        • ᕕ(ꐦ°᷄д°᷅)ᕗ❌ (5)
      • 🚀 from error to study (142)
        • AI (1)
        • Cloud (2)
        • DB (12)
        • Front-End (16)
        • Github (14)
        • Java (39)
        • Mac (7)
        • Normal (29)
        • Server (22)
      • 📘 certificate (44)
        • 📘 리눅스마스터1급 (1)
        • 📘⭕️ 정보처리기사 (40)
        • 📘⭕️ SQLD (3)
      • 📗 self-study (234)
        • 📗 inflearn (35)
        • 📗 생활코딩 (8)
        • 📗 KH정보교육원 당산지원 (190)
      • 🎨 Scoop the others (0)
        • 📖 Peeking into other people.. (0)
        • 🇫🇷 (0)
        • 📘⭕️ 한국사능력검정시험 심화 (11)
        • 오블완 (4)
  • 인기 글

  • hELLO· Designed By정상우.v4.10.1
천재강쥐
[java] controller에서 jsp로 값을 보내지 못함
상단으로

티스토리툴바