1117_Spring : 쪽지보내기 예제

1117_Spring : 쪽지보내기 예제

package com.sp.app.note; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @Controller("note.noteController") @RequestMapping("/note/*") public class NoteController { @Autowired private NoteService service; @RequestMapping(value="request", method=RequestMethod.GET) public String form(Model model) { List listFriend = service.listFriend(); model.addAttribute("friends", listFriend); return "note/write"; } /* @RequestMapping(value = "request", method = RequestMethod.POST) public String formSubmit(Note dto, Model model) throws Exception { model.addAttribute("msg", dto.getMsg()); model.addAttribute("list", dto.getRecipient()); return "note/result"; } */ @RequestMapping(value = "request", method = RequestMethod.POST) public String formSubmit(Note dto, Model model) throws Exception { model.addAttribute("dto", dto); return "note/result"; } }

<%@ page contentType="text/html; charset=UTF-8"%> <%@ page trimDirectiveWhitespaces="true" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> Insert title here * { margin: 0; padding: 0; box-sizing: border-box; } body { font-size: 14px; font-family: "맑은 고딕", 나눔고딕, 돋움, sans-serif; } a { color: #000; text-decoration: none; cursor: pointer; } a:active, a:hover { text-decoration: underline; color: #F28011; } .btn { color: #333; border: 1px solid #333; background-color: #fff; padding: 4px 10px; border-radius: 4px; font-weight: 500; cursor:pointer; font-size: 14px; font-family: "맑은 고딕", 나눔고딕, 돋움, sans-serif; vertical-align: baseline; } .btn:hover, .btn:active, .btn:focus { background-color: #e6e6e6; border-color: #adadad; color:#333; } .boxTF { border: 1px solid #999; padding: 5px 5px; background-color: #fff; border-radius: 4px; font-family: "맑은 고딕", 나눔고딕, 돋움, sans-serif; vertical-align: baseline; } .selectField { border: 1px solid #999; padding: 4px 5px; border-radius: 4px; font-family: "맑은 고딕", 나눔고딕, 돋움, sans-serif; vertical-align: baseline; } .boxTA { border:1px solid #999; height:150px; padding:3px 5px; border-radius:4px; background-color:#fff; font-family: "맑은 고딕", 나눔고딕, 돋움, sans-serif; resize : none; vertical-align: baseline; } textarea:focus, input:focus { outline: none; } .title { width:100%; font-size: 16px; font-weight: bold; padding: 13px 0; } .container { width: 400px; margin: 30px auto; } .note-table { width: 100%; border-spacing: 0; border-collapse: collapse; } .note-table th, .note-table td { padding: 5px 0; } .left { text-align: left; padding-left: 7px; } .center { text-align: center; } .right { text-align: right; padding-right: 7px; } $(function() { $("#btnRight").click(function() { $("#friends option:selected").each(function() { $(this).appendTo("#recipient"); }); }); $("#btnAllRight").click(function() { $("#friends option").each(function() { $(this).appendTo("#recipient"); }); }); $("#btnLeft").click(function() { $("#recipient option:selected").each(function() { $(this).appendTo("#friends"); }); }); $("#btnAllLeft").click(function() { $("#recipient option").each(function() { $(this).appendTo("#friends"); }); });$ }); function sendOk() { if($("#recipient option").length === 0) { alert("받는 사람을 먼저 추가하세요..."); return; } $("#recipient option").prop("selected", true); if(! $("#msg").val().trim() ) { alert("내용을 입력하세요..."); $("#msg").focus(); return; } var f = document.noteForm; f.action = "${pageContext.request.contextPath}/note/request"; f.submit(); } | 쪽지 보내기 친구목록 받는사람 ${vo.userName} > >> < << 메시지 쪽지보내기

<%@ page contentType="text/html; charset=UTF-8"%> <%@ page trimDirectiveWhitespaces="true" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> Insert title here * { margin: 0; padding: 0; box-sizing: border-box; } body { font-size: 14px; font-family: "맑은 고딕", 나눔고딕, 돋움, sans-serif; } a { color: #000; text-decoration: none; cursor: pointer; } a:active, a:hover { text-decoration: underline; color: #F28011; } .title { width:100%; font-size: 16px; font-weight: bold; padding: 13px 0; } .container { width: 400px; margin: 30px auto; } | 쪽지 보내기 결과 받는사람 ${vo} 메시지 ${dto.msg}

from http://development-writing.tistory.com/351 by ccl(S) rewrite - 2021-11-22 04:28:12