마스터욱
Toggle navigation
  • 회원가입 | 정보찾기
ICON NAVIGATION
정보수정 쪽지함 주변맛집 익명채팅
공지사항 채팅 개발문의 방명록
  • MAIN NAVIGATION
  • 메인
  • 마스터욱 공간
    • 마스터욱 소개
    • 개발 리스트
    • 공지사항
    • 방명록
  • 마스터욱 외부자료
    • 네이버
    • 티스토리
    • 깃허브(github)
  • 개인 프로젝트
    • 랜덤 이성 채팅
    • Auto 크롤링
    • Javascript 카카오 채팅
    • 파이썬 뉴스매매
    • C# 키움 주식 자동매매
    • C# 키움 주식 패턴 분석
    • PHP 욱보드
    • 업비트 자동매매 개발
    • 업비트 자동매매 일지
  • 개발 의뢰
    • 개발 문의
    • 개발 견적
    • 개발 피드백
    • FAQ
  • 개발 경험 Tip
    • PHP
    • JSP
    • HTML
    • Javascript
    • Android
    • C#
    • MySQL
    • Linux
    • Python
    • NodeJS
    • React
    • Vue.js
    • Flutter
    • 정규식
    • 기타
  • 커뮤니티
    • 자유게시판
    • 추천사이트
    • 영화
    • 여행
    • 유머
    • Overseas News
  • 맛집&즐길 거리 탐방
    • 맛집 정보
    • 즐길 거리 정보
    • 내 주위 맛집&즐길 거리
  • 공유 사진
    • 음식
    • 여행
    • 캐릭터
    • 배경
    • 기타
    • 이모티콘
    • 일러스트
  • 놀이터
    • 블록뽀시기
    • 트레이딩뷰
    • 로또 시뮬레이션
    • 쳇쳇 익명 채팅
    • 랜덤 이성 채팅
    • AI 채팅
    • 미니 채팅
    • 바이너리 테스트
    • 마번호 생성기
    • 바카라 시뮬레이션
    • 홀짝점수 테스트
    • 로또 분석기
SITE STATISTICS
  • - 명 현재 접속자
  • 1,932 명 오늘 방문자
  • 2,745 명 어제 방문자
  • 5,192 명 최대 방문자
  • 679,281 명 전체 방문자
  • 2,569 개 전체 게시물
  • 496 개 전체 댓글수
Facebook Twitter GooglePlus KakaoStory NaverBand
  1. 홈
  2. JSP
목록으로

#스마트에디터 장착하기, #Spring, #Jsp, #Java, #위지윅, #에디터

마스터욱 0 362 0 0 2017-03-08 14:42:30

그리 어렵지는 않다라고 하면서 하루종일 삽질했음...

Controller 소스부분 구현이 제일 난관이였습니다.

 

파일업로드 JSP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
 
<script type="text/javascript" src="../plugin/smarteditor/js/HuskyEZCreator.js" charset="utf-8"></script>
<script type="text/javascript">
    var EditorObj = []; //전역변수
    $(document).ready(function(){
        //스마트에디터 프레임생성
        nhn.husky.EZCreator.createInIFrame({
            oAppRef: EditorObj,
            elPlaceHolder: "editor",
            sSkinURI: "../plugin/smarteditor/SmartEditor2Skin.html",
            htParams : {
                // 툴바 사용 여부 (true:사용/ false:사용하지 않음)
                bUseToolbar : true,            
                // 입력창 크기 조절바 사용 여부 (true:사용/ false:사용하지 않음)
                bUseVerticalResizer : true,    
                // 모드 탭(Editor | HTML | TEXT) 사용 여부 (true:사용/ false:사용하지 않음)
                bUseModeChanger : true,
            }
        });
        
        $("#noticeForm").validate({
              rules : {
                  title : {
                    required : true,
                    minlength : 1,
                    maxlength : 255
                },
                content : {
                    required : true,
                    minlength : 8,
                    maxlength : 20
                }
            },
            messages : {
                title : {
                    required : '제목을 입력해주세요.'
                },
                content : {
                    required : '내용을 입력해주세요.'
                }
            },
            errorClass : "form-invalid",
            submitHandler : function(form){
                EditorObj.getById["editor"].exec("UPDATE_CONTENTS_FIELD", []);
                //console.log($("#editor").val());
                   form.submit();
              }
        });
    });    
</script>
 
<h3 class="sub-header">공지사항</h3>
 
<form id="noticeForm" name="noticeForm" class="form-horizontal" method="post" enctype="multipart/form-data" action='noticeSave'>
<div class="form-group">
    <div class="col-sm-12">
        <input type="text" class="form-control" id="title" name="title" placeholder="제목을 입력해주세요.">
    </div>
</div>
<div class="form-group">
    <div class="col-sm-12">
        <input type="file" class="form-control" id="file" placeholder="첨부파일을 넣어주세요.">
    </div>
</div>
<div class="form-group">
    <div class="col-sm-12">
        <textarea id="editor" name="content" style="width:100%;height:500px;"></textarea>
    </div>
</div>
<div class="form-group">
    <div class="col-sm-12">
        <button type="submit" class="btn btn-primary">저장</button>
    </div>
</div>
</form>
 
Colored by Color Scripter
cs

 

 

 

파일업로드 Controller

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
    @RequestMapping(value="/photoUpload", method=RequestMethod.POST)
    public @ResponseBody String photoUpload(MultipartHttpServletRequest request, HttpServletResponse response, Model model){
        System.out.println("photoUpload controller");
 
        try {
            Iterator<String> itr = request.getFileNames();
            MultipartFile mpf;
 
            while (itr.hasNext()) {
                mpf = request.getFile(itr.next());
                System.out.println(mpf.getOriginalFilename());
                
                String filename = mpf.getOriginalFilename();
                String filename_ext = filename.substring(filename.lastIndexOf(".")+1);
                filename_ext = filename_ext.toLowerCase();
                String dftFilePath = request.getSession().getServletContext().getRealPath("/");
 
                //파일 기본경로 _ 상세경로
                SimpleDateFormat formatter = new SimpleDateFormat("yyyyMM");
                String folderName = formatter.format(new java.util.Date());                
                String filePath = dftFilePath + "images" + File.separator + "photoUpload" + File.separator + folderName + File.separator;
                //C:\Users\wook\Desktop\eGov\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\BizV3\images\photo_upload\201703
                System.out.println("filePath = " + filePath);
 
                String realFileNm = "";
                formatter = new SimpleDateFormat("yyyyMMddHHmmss");
                String today= formatter.format(new java.util.Date());
                realFileNm = today+UUID.randomUUID().toString() + filename.substring(filename.lastIndexOf("."));
                String rlFileNm = filePath + realFileNm;
                //C:\Users\wook\Desktop\eGov\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\BizV3\images\photo_upload\201703\2017030809570465a56af2-b3d6-4283-a0ae-1f0b19434864.jpg
                System.out.println("rlFileNm = " + rlFileNm);
                
                try {                
                    File file = new File(rlFileNm);
                    if(!file.exists()) {
                        file.mkdirs();
                    }                    
                    mpf.transferTo(file);
                } catch (IOException e) {
                    e.printStackTrace();
                }                
 
                String json = "";
                json +=    "{\"files\":[{";
                json +=    "\"name\":\""+realFileNm+"\",";
                json +=    "\"url\":\""+request.getContextPath()+"/images/photoUpload/"+folderName+"/"+realFileNm+"\"";
                /*                
                json +=    "\"width\":\"500\",";
                json +=    "\"height\":\"749\"";
                json +=    "\"oriname\":\"b9548a3f8c02df7d3e95074e2df979b7.jpg\",";                
                json +=    "\"size\":183397,";
                json +=    "\"type\":\"image\/jpeg\",";
                json +=    "\"deleteUrl\":\"http:\/\/story84.com\/plugin\/smarteditor\/photo_uploader\/popup2\/php\/?file=9a3ddde7401c4c064b7277a021b669fd_1488939962_4608.jpg\",";
                json +=    "\"deleteType\":\"DELETE\"";
                */
                json +=    "}]}";
                
                return json;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        
        return "";
    }
Colored by Color Scripter
cs

 

0
0

목록

Facebook Twitter GooglePlus KakaoStory NaverBand
0 Comments

비밀번호 확인

확인
댓글은 자신을 나타내는 '얼굴'입니다. *^^*
등록
자동등록방지 숫자를 순서대로 입력하세요.

댓글수정


글쓰기
검색
번호 제목 이름 날짜 조회
  • 18
    JAVA WEB - GZIP 압축전송
    마스터욱
    조회수 165   22-11-07 16:28
    마스터욱
    22-11-07 16:28
    165
  • 17
    Eclipse Server Project Facets 이클립스 프로젝트 Server 설정안될 때
    마스터욱
    조회수 157   20-09-25 00:14
    마스터욱
    20-09-25 00:14
    157
  • 16
    이클립스에 Dynamic Web Project 없을 때 해결법
    마스터욱
    조회수 152   20-09-25 00:14
    마스터욱
    20-09-25 00:14
    152
  • 15
    Server Tomcat v7.0 Server at localhost failed to start.
    마스터욱
    조회수 171   20-09-24 21:58
    마스터욱
    20-09-24 21:58
    171
  • 14
    eclipse New Server 에서 Tomcat이 안 나올때 추가 방법
    마스터욱
    조회수 166   20-09-24 21:31
    마스터욱
    20-09-24 21:31
    166
  • 13
    이클립스 Lombok 사용시 Warning 문제 해결
    마스터욱
    조회수 170   20-09-24 16:27
    마스터욱
    20-09-24 16:27
    170
  • 12
    could not find tools.jar in the active JRE
    마스터욱
    조회수 175   20-09-24 16:05
    마스터욱
    20-09-24 16:05
    175
  • 11
    이클립스 퀵서치(quick search) 설치방법
    마스터욱
    조회수 244   20-09-24 15:43
    마스터욱
    20-09-24 15:43
    244
  • 10
    이클립스에서 파일 오픈시 한글이 깨지는 현상수정방법
    마스터욱
    조회수 242   20-09-24 15:29
    마스터욱
    20-09-24 15:29
    242
  • 9
    gradle project import
    마스터욱
    조회수 150   17-06-26 21:13
    마스터욱
    17-06-26 21:13
    150
  • 8
    서버 재시작 없이 Spring 웹 프로젝트 개발하기
    마스터욱
    조회수 171   17-06-18 03:52
    마스터욱
    17-06-18 03:52
    171
  • 7
    #스마트에디터 장착하기, #Spring, #Jsp, #Java, #위지윅, #에디터
    마스터욱
    조회수 363   17-03-08 14:42
    마스터욱
    17-03-08 14:42
    363
  • 6
    스프링에서의 POST/GET 한글처리
    마스터욱
    조회수 189   17-03-03 12:09
    마스터욱
    17-03-03 12:09
    189
  • 5
    JAVA, JSP, SPRING 동영상 강좌
    마스터욱
    조회수 152   17-03-01 18:41
    마스터욱
    17-03-01 18:41
    152
  • 4
    RequestMapping 사용방법
    마스터욱
    조회수 204   17-02-13 13:52
    마스터욱
    17-02-13 13:52
    204
  • 3
    톰켓(tomcat)에 프로젝트 등록하는 방법
    마스터욱
    조회수 142   17-02-07 03:11
    마스터욱
    17-02-07 03:11
    142
  • 2
    eGov, 이클립스 SVN 설치하기
    마스터욱
    조회수 207   17-02-07 02:28
    마스터욱
    17-02-07 02:28
    207
  • 1
    [57] JSP Spring MVC 게시판 만들기 [57]
    마스터욱
    조회수 262   17-01-13 00:50
    마스터욱
    17-01-13 00:50
    262
글쓰기
검색

Search

개인정보처리방침
마스터욱. All rights reserved.

Close

0 명 접속중
Time Loading...