반응형

* 윈도우에서 우분투로 원격접속

  • xrdp 설치
    • sudo apt update
    • sudo apt install --no-install-recommends xrdp (--no-install-recommends 옵션써야지 필수만 설치함 안그러면 너무 많이 설치)
  • xrdp 실행확인, 시작, 중지
    • systemctl status xrdp -> Active(running)이라고 나오면 돌아가는 것
    • sudo service xrdp restart
    • sudo service xrdp start
    • sudo service xrdp stop
  • xrdp port변경, 기본은 3389
    • sudo vi /etc/xrdp/xrdp.ini ->여기서 port찾아서 변경
  • 그외에 xrdp관련 에러해결법
    • startwm.sh 수정: 정확히 이게 무슨용도로 뭐하는건진 모르겠지만 에러시 해결방법이라고 나옴, 이건 안해도 사내 윈도우에서 사내우분투로 접속시 문제가 없었음, 자세한 내용은 https://lapina.tistory.com/147 https://ko.linux-console.net/?p=393
      • sudo sed -i.bak '/fi/a #xrdp multiple users configuration \n mate-session \n' /etc/xrdp/startwm.sh
    • 접속은 됬는데 반응이 없음
      • xorgxrdp설치 혹은 기존 우분투 세션 로그아웃되어 있는지 확인, 기존 로그인이 되어 있으면 반응이 없
    • 접속자체가 안됨
      • 클라우드PC에서는 접속자체가 안되었는데 3389포트를 3388로 변경하니까 됨, 포트가 막혀있었나봄
    • 속도가 느리다면 
      • cmd>mstsc>원격접속 실행창에서 해상도, 색농도 조절가능한데 낮춰주면 좀더 빨라질지도
  • xorgxrdp: xrdp환경에서 xorg(또는 X11) GUI를 사용할 수 있도록 해준다고 하는데... 설치안하면 원격연결해서 로그인해도 화면출력이 안될거라고 함, 처음에 진짜 접속이 잘 안됐는데 이거 설치후 하니까 사내 윈도우에서 사내우분투로 연결이 되었음
    • sudo apt install xorgxrdp
    • sudo apt install xorgxrdp-hwe-18.04 (우분투18.4의 경우)
  • xfce: 우분투 서버인 경우 GUI설치안되어 있으므로 GUI를 사용안하도록 되어 있다면 설치해야 한다고함, ubuntu-desktop과 xfce4를 많이 추천하는데 xfce4가 가볍다고 함
    • sudo apt install xfce4
    • echo xfce4-session >~/.xsession (xrdp를 xfce4의 GUI로 연결하기 위해 수행해야함)
  • xserver-xorg-input-all: 이거 없으면 키보드와 마우스 입력이 안된다고 하는데, 사내 윈도우에서 사내리눅스로 접속시 설치안해도 문제없었음
    • sudo apt install xserver-xorg-input-all
  • 방화벽 설정
    • 방화벽 허용
      • sudo ufw allow (xrdp사용하는 포트, 기본은 3389)/tcp (예: sudo ufw allow 3389/tcp)
    • 특정 ip로 방화벽 허용
      • sudo ufw allow from 192.168.2.0/24 to any port 3389
    • sudo ufw status 방화벽 상태확인, 방화벽안쓰고 있었다면 구지 설정안해도 됨
    • sudo ufw reload 방화벽 재기동

 

 

반응형

'etc > linux' 카테고리의 다른 글

ls -al 결과의 의미  (0) 2022.04.18
linux 사양확인  (0) 2022.04.18
linux java process 찾기, java 실행  (0) 2020.01.31
리눅스 PC에 백업  (0) 2019.07.26
Ubuntu 단축키  (0) 2019.04.26
반응형

[mySQL 스케쥴러동작시 커맨드]
ps -ef | grep java | grep "com.lge.ibis.manager.scheduler.mgmt.SchdManager"
ps -ef | grep java | grep nSvcBasDaemon
ps -ef | grep java | grep "com.lge.ibis.manager.scheduler.mgmt.TestManager"
java -cp /:/home/sdpbat/ibs/let-it-go/lib/*:/home/sdpbat/ibs/let-it-go/crawler-manager-1.0.0.jar com.lge.ibis.manager.scheduler.mgmt.TestManager $input
nohup java -Xms512m -Xmx1024m -XX:MaxPermSize=512m -XX:+UseParallelGC -cp /:/home/sdpbat/ibs/let-it-go/lib/*:/home/sdpbat/ibs/let-it-go/crawler-manager-1.0.0.jar com.lge.ibis.manager.scheduler.mgmt.SchdManager

반응형

'etc > linux' 카테고리의 다른 글

linux 사양확인  (0) 2022.04.18
linux 원격접속  (0) 2022.04.07
리눅스 PC에 백업  (0) 2019.07.26
Ubuntu 단축키  (0) 2019.04.26
시스템 관련  (0) 2019.04.23
반응형

리눅스 PC에 백업하실 분들은

 

sudo apt-get install vsftpd

sudo vi /etc/vsftpd.conf

 

# enable write permission

write_enable=YES

 

하셔서 리눅스에 ftp 서버 설치하고,

파일 백업하시면 됩니다.

ftp 클라이언트는 fileZilla 같은 것 쓰시면 됩니다.

 

sftp 사용을 권장한다고 해서, 이것 저것 해보다가 잘 안되어서

위의 방법을 권장해드립니다.

 

반응형

'etc > linux' 카테고리의 다른 글

linux 원격접속  (0) 2022.04.07
linux java process 찾기, java 실행  (0) 2020.01.31
Ubuntu 단축키  (0) 2019.04.26
시스템 관련  (0) 2019.04.23
troubleshooting  (0) 2019.04.02
반응형

화면캡쳐


 전체 화면 캡쳐  활성화 창 캡쳐  선택 영역 캡쳐
 그림 파일로 저장 Print  Alt + Print   Shift + Print
 클립 보드로 복사  Ctrl + Print Ctrl + Alt + Print  Ctrl + Shift + Print 

단축키 변경방법

환경설정 (전체설정) -> 키보드 -> 바로가기 -> 스크린샷' 메뉴에 보면 위 6 종류 단축키 설정가능

출처: https://harryp.tistory.com/595 [Park's Life]

 

창 조절: Ctrl + Window Key + 화살표키 (Windows에서 Window Key + 화살표키와 동일기능)

반응형

'etc > linux' 카테고리의 다른 글

linux java process 찾기, java 실행  (0) 2020.01.31
리눅스 PC에 백업  (0) 2019.07.26
시스템 관련  (0) 2019.04.23
troubleshooting  (0) 2019.04.02
Linux 명령어  (0) 2019.03.29
반응형

Disk 관련

  • hdd인지 sdd인지 확인: rota가 1이면 hdd, 0이면 sdd, ROTA means rotational device (1 if true, 0 if false)
    • lsblk -d -o name,rota
    • cat /sys/block/sda/queue/rotational
  • disk 모델, 제조사 등 확인: http://fibrevillage.com/storage/599-how-to-tell-if-a-disk-is-ssd-or-hdisk-on-linux
    • cat /proc/scsi/scsi
  • disk 관리 관련: https://cptyun.tistory.com/3
    • df : 디스크 마운트 상태 및 용량 확인
    • fdisk : 디스크 파티션 관리
    • mkfs.ext4 : EXT4 형식으로 디스크 포맷
    • mount / umount : 디스크 마운트 / 언마운트
    • fstab : 시스템 부팅시에 디스크 마운트
  • df -h (disk free -human readable): 디스크 마운트 상태 및 용량 확인
  • lsblk (list block devices) https://linoxide.com/linux-command/linux-lsblk-command/
    • NAME :This is the device name.
    • MAJ:MIN :This column shows the major and minor device number.
    • RM :This column shows whether the device is removable or not. Note in this example the device sdb and sr0 have their RM values equals to 1 indicating they are removable.
    • SIZE :This is column give information on the size of the device. For example 298.1G indicate the device is 298.1GB and 1K indicate the device size is 1KB.
    • RO :This indicates whether a device is read-only. In this case all devices have a RO=0, indicating they are not read only.
    • TYPE :This column shows information whether the block device is a disk or a partition(part) within a disk. In this example sda and sdb are disks while sr0 is a read only memory (rom).
    • MOUNTPOINT :This column indicates mount point on which the device is mounted.

디스크 마운트 상태 및 용량 확인

Memory 관련

  • free -h : 전체 메모리와 가용 메모리 human readable하게 알려줌
  • top: Windows 작업관리자 같은 것 - top
  • proc/meminfo
  • ps -ef
    • ps -ef --sort -rss, rss(Resident Set Size) : 물리 메모리를 실제 점유하고 있는 크기
    • 가장 위에 있는 프로세스가 물리 메모리를 가장 많이 점유하고 있음!
    • ps -eo user,pid,ppid,rss,size,vsize,pmem,pcpu,time,comm --sort -rss | head -n 11
  • dmidecode: 설치된 RAM 하드웨어 정보 표시.
    • 예) dmidecode -t 17, type 17이 RAM. (그 외 L1/L2 cache 등)

https://m.blog.naver.com/jayeonsaram/220647978281

반응형

'etc > linux' 카테고리의 다른 글

linux java process 찾기, java 실행  (0) 2020.01.31
리눅스 PC에 백업  (0) 2019.07.26
Ubuntu 단축키  (0) 2019.04.26
troubleshooting  (0) 2019.04.02
Linux 명령어  (0) 2019.03.29
반응형

gzip: stdout: No space left on device   

https://askubuntu.com/questions/223248/gzip-stdout-no-space-left-on-device-while-upgrading-the-kernel

https://ubuntuforums.org/showthread.php?t=2362183

  • 먼저 disk용 가용공간 확인
    • df -h: disk free 줄임말, -h는 human readable, 사람이 보기편한 MB,GB 단위로 출력해줌
  • 다운로드된 커널 이미지 목록 확인
    • dpkg -l | grep linux-image: debian package manager? .deb 패키지의 설치, 삭제, 정보 확인등을 위해 사용되는 명령어
  • 현재 사용되는 커널이미지 확인
    • uname -r: find your currently running kernel (uname=UNIX name)
  • 현재 사용되는 것 외에 불필요한 것을 삭제 -> 다시 df 확인하니 가용공간 늘어나고 문제해결됨

Visual Studio Code에서 bootstrap table -  yarn start 잘 되다가 다음날 이런 에러 발생...

Error: ENOSPC: System limit for number of file watchers reached, watch '/home/ibs/react/bootstap-table/public'
    at FSWatcher.start (internal/fs/watchers.js:165:26)
    at Object.watch (fs.js:1274:11)
.....이하 에러메세지 생략

해결책) https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

inotify watcher increase해야함

  • get your current inotify file watch limit) cat /proc/sys/fs/inotify/max_user_watches -> 8192 였음
  • max value 524388로 increase) echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
  • 다시 cat /proc/sys/fs/inotify/max_user_watches 하니 524388로 늘어남

visual studio code linux 문서에서 관련사항 설명되어 있음 https://code.visualstudio.com/docs/setup/linux

 

 

 

반응형

'etc > linux' 카테고리의 다른 글

linux java process 찾기, java 실행  (0) 2020.01.31
리눅스 PC에 백업  (0) 2019.07.26
Ubuntu 단축키  (0) 2019.04.26
시스템 관련  (0) 2019.04.23
Linux 명령어  (0) 2019.03.29
반응형
hostname -I ip addr show /sbin/ifconfig ip address 확인 (=ipconfig inWindows)
host ftp1.xumo.com
ping ftp1.xumo.com
domain에 해당하는 IP 찾기
nc -vz GB.internal.emp.lgsmartplatform.com 80

NetCat options
-v: Vebose(장황한, 상세한) 상세결과 출력
-z : Zero-I/O mode [used for scanning]
nc -h 하면 help message, 상세옵션 나옴
특정 서버에 특정 port로 접근이 되는지 확인할 때 사용
ping ping은 ICMP protocol이용하는 것으로 특정 port로 접근가능한지는 테스트못함,
ip layer를 통해 internet 연결이 되는지만 확인가능
tar czvf conory.tar.gz /home/conory
tar xzvf conory.tar.gz
압축할때
압축풀때
chmod 755 파일명 파일권한 변경
read=4, write=2, x=1
755 = 4+2+1, 4+0+1, 4+0+1
644 = 4+2+0, 4+0+0, 4+0+0
find -name 'webos.conf'
find / -name '*.conf'
find / -name 'ab*'
find / -name 'ab*' -type d
현재 디렉토리에서 webos.conf파일 찾기
root아래에서 즉, 전체 디렉토리에서 conf확장자를 가진 파일 찾기
전체 디렉토리에서 ab로 시작하는 파일 찾기
전체 디렉토리에서 ab로 시작하는 디렉토리 찾기
grep [option] [검색 문자열] [파일명]
grep -rc home_amazon 
grep -rl home_amazon 
grep CATALINA_OUT ./*.sh 
옵션
-c 검색할 문자열이 속한 행이 개수를 출력한다.
-H 파일 이름과 함께 출력을 한다.
-i 대소문을 구분하지 않고 출력을 한다.
-n 찾으려는 문자가 속해있는 행의 번호와 같이 출력 한다.
-r 현재 경로부터 하위경로까지 검색해서 출력을 한다.
-v 찾으려는 문자가 없는 행을 출력 한다.
-w 패턴 표현식을 하나의 단어로 취급하여 검색


폴더내 모든 파일에 대해 home_amazon 검색갯수 출력
폴더내 home_amazon이 들어있는 파일에 대해 그 리스트 출력
sh확장자를 가진 파일중에서 CATALINA_OUT을 검색

















ssh seongro@10.186.119.212
ssh seongro@10.186.119.212 -p1022
exit
ssh 연결
22번아닌 1022번포트로 연결할 때
연결종료
sudo minicom serial cable 연결
   

 

TFTP
sudo apt-get install xinetd tftp tftpd
sudo vi /etc/xinetd.d/tftp
service tftp { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /tftpboot disable = no per_source = 11 cps = 100 2 flags = IPv4 }
sudo mkdir /tftpboot ~$ sudo chmod 777 /tftpboot
~$ sudo /etc/init.d/xinetd restart
~$cd /tftpboot ~$ vi test.txt 아무런 문자열을 입력하고 저장한 후, VI 에디터를 종료합니다.
~$ cd /tmp // 임시 디렉토리로 이동
~$ tftp localhost // tftp 서버와 연결
tftp> get test.txt // test.txt 다운로드
Received 6 bytes in 0.0 seconds
tftp> quit
~$ ls -al // 다운 받은 파일 확인
합계 76 drwxrwxrwt 14 root root 4096 2009-05-25 13:35 . drwxr-xr-x 22 root root 4096 2009-05-25 13:30 .. drwxrwxrwt 2 root root 4096 2009-05-25 13:26 .ICE-unix -r--r--r-- 1 root root 11 2009-05-25 13:22 .X0-lock drwxrwxrwt 2 root root 4096 2009-05-25 13:22 .X11-unix drwx------ 2 jwjw jwjw 4096 2009-05-25 13:26 .esd-1000 drwx------ 2 jwjw jwjw 4096 2009-05-25 13:27 ssh-CxzfZm6269 -rw-r--r-- 1 jwjw jwjw 5 2009-05-25 13:35 test.txt -rw------- 1 root root 0 2009-05-25 13:22 tmp.btyMJW5940
~$ cat test.txt // 내용 출력 tftp로 전송할 파일

 

ps -> Process Status의 준말인가

대표적인 사용옵션: ps -ef     e는 모든 프로세스를, f는 full format으로 보여줘라는 뜻결과는 UID        PID  PPID  C STIME TTY          TIME CMD 순으로 정렬하여 나옴ps -ef | grep com.lge.ibis.crawler.watch.ViewershipCrawler | head -1 | awk '{print $2}' | xargs kill                -> 첫번째 행 process kill
ps -ef | grep com.lge.ibis.crawler.watch.ViewershipCrawler | head -2 | tail -1 | awk '{print $2}' | xargs kill    -> 두번째 행 process kill head -1은 첫번째 행까지head -2는 두번째 행까지 (즉 1행 + 2행)tail -1은 마지막 첫행tail -2은 마지막 첫행부터 2행까지


특정 port 번호를 사용하는 process (PID) 찾는 방법 3가지

  1. netstat -ntp | grep 50064  결과) tcp        0      0 ::ffff:165.244.145.18:50064 ::ffff:10.185.19.36:3310    ESTABLISHED 24664/java 
  2. lsof -i tcp:8080 -> Q2 sdpbat 계정으로 실행시 없는 명령어라 함 ㅠ
  3. fuser 8080/tcp -> Q2 sdpbat 계정으로 실행시 없는 명령어라 함 ㅠ

Crontab 

현재 사용자 [root@zetawiki ~]# crontab -l다른 사용자 [root@zetawiki ~]# crontab -l -u testuser직접등록 crontab -e작업삭제 crontab -r* * * * * 수행할 명령어 ┬ ┬ ┬ ┬ ┬ │ │ │ │ └───────── 요일 (0 - 6) (0 =일요일) │ │ │ └────────── 월 (1 - 12) │ │ └─────────── 일 (1 - 31) │ └──────────── 시 (0 - 23) └───────────── 분 (0 - 59)

  • * * * * * /root/every_1min.sh                        → 매 1분마다 /root/every_1min.sh 를 수행 (하루에 1440회[2])
  • 15,45 * * * * /root/every_30min.sh             → 매시 15분, 45분에 /root/every_30min.sh 를 수행 (하루에 48회[3])
  • */10 * * * * /root/every_10min.sh                → 10분마다 /root/every_10min.sh 를 수행 (하루에 144회[4])
  • 0 2 * * * /root/backup.sh                              → 매일 02:00에/root/backup.sh 를 수행 (하루에 1회)
  • 30 */6 * * * /root/every_6hours.sh              → 매 6시간마다 수행(00:30, 06:30, 12:30, 18:30)
  • 30 1-23/6 * * * /root/every_6hours.sh        → 1시부터 매 6시간마다 수행(01:30, 07:30, 13:30, 19:30)
  • 0 8 * * 1-5 /root/weekday.sh                        → 평일(월요일~금요일) 08:00
  • 0 8 * * 0,6 /root/weekend.sh                        → 주말(일요일, 토요일) 08:00

로그: /var/log/cron에 변경/수행 이력이 기록됨

00 09 * * * /home/ibs/crawler/watch/crawler.sh restart >> /home/ibs/logs/crontab.log 2>&1

00 02 * * * /usr/bin/find /home/ibs/crawler/crawler_daily_checker/log -name "*.log.201*" -atime +7(7일지난거) -exec rm -rf {}(find로 찾은 애들가리킴) \;(exec option의 끝을 표시하기 위해 \;써줌) &> /dev/null

 


sudo: 현재 계정에서 다른 계정의 권한만 빌려서 일회성으로 명령어 실행

su: 로그아웃하지 않고 다른 계정으로 전환

su -: 로그아웃하지 않고 다른 계정으로 전환 + 그 계정의 환경변수 적용 

sdpbat 으로 계정변경: sudo su - sdpbat , su - sdpbat

반응형

'etc > linux' 카테고리의 다른 글

linux java process 찾기, java 실행  (0) 2020.01.31
리눅스 PC에 백업  (0) 2019.07.26
Ubuntu 단축키  (0) 2019.04.26
시스템 관련  (0) 2019.04.23
troubleshooting  (0) 2019.04.02
반응형

대소문자 구분

   
 oracle  x
 mySQL  x (display는 다르게 나오지만 호환됨), 컬럼 내부 값이 설정에 따라 대소문자 구분할수도 안할수도 있음
 java  o
 html  x 
 xml  o 
 javascript  o
 react  o

 

jQuery $()

JSP EL ${}

myBatis #{} (${}도 쓰이지만 보안 등의 문제로 #{}를 쓰는 것이 바람직)

 

element, attribute, parameter, argument, property, key-value, 

   input  output
 servlet  Request attribute  Response attribute
 myBatis  parameterType  resultType, resultMap
     
     

 

XML

element=요소, attribute=속성

<요소이름 속성1="속성값" 속성2="속성값"... >

 

반응형

'etc' 카테고리의 다른 글

504 gateway time-out 에러 해결방법  (0) 2022.09.08
proxy/reverse proxy, web server, load balancer 개념  (0) 2022.09.08
character encoding  (0) 2022.07.11
app-ads.txt  (0) 2022.05.04
Web Application Architecture 교육 (2019/03/11~03/15)  (0) 2019.03.11
반응형

3/11: HTML, CSS

    • 구분자 역할: 요즘은 XML이 대신함
    • 기능적 역할: 요즘은 거의 CSS가 대신함
    • 주로 쓰는 건 3가지
      • <a href..
        • <a href="${root}/board/read.do?boardNumber=${board.boardNumber}">${board.subject}</a>
        • <a> 태그로 요청시 post로 전달할 수 있는 방법은?
      • <img>
      • <form> https://www.w3schools.com/html/html_forms.asp
        • parameter
          • <input type="text" name="firstname" value=""/>
          • input(name, value) ====> Request객체의 attribute(key, value) 가 된다!!!
          • name이 없으면 서버에 아예 전달되지 않음
        • request보내기 
          • 한 form에서 여러 sumit 버튼 이용하기 
  • <form method="post" name="form"> -> action은 써도 소용없음 "javascript: form.action='/manage/update';"때문에 submit버튼 누를때마다 바뀌므로
  •     <input type="text" value="value1" name="key1" /> -> 얘는 Request Attribute로 전달
  •     <input type="text" value="value2" name="key2" /> -> 얘는 Request Attribute로 전달
  •     <input type="submit" value="수정" onclick="javascript: form.action='/manage/update';"/> 
  •     <input type="submit" value="삭제" onclick="javascript: form.action='/manage/delete';"/>
  •      <input type="button"...>에서는 form.action으로 전달못함?
  • </form>
            • 아래와 같이 하면 구지 <form> tag와 같이 쓰지 않아도 됨, but html5부터 지원하므로 IE9이하 브라우저에선 작용을 안함
<input type="submit" value="수정" formaction="/manage/update">
<input type="submit" value="삭제" formaction="/manage/delete">
          • https://kutar37.tistory.com/entry/%ED%95%9C%EA%B0%9C%EC%9D%98-Form%EC%97%90%EC%84%9C-%EC%97%AC%EB%9F%AC%EA%B0%9C-Submit-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0
  • block vs inline
    • block요소: 줄바꿈O, <div>
    • inline요소: 줄바꿈X, <span>
    • CSS는 block요소에 적용해야 제대로 적용됨, span, font등 inline 요소에 적용하면 width, height, margin, padding등이 의도한 것과 다르게 적용이 안되거나 함, 그럴때는 display: inline-block 속성을 줘서 inline애들을 inline-block으로 바꿔줘보자 
    • 참고: https://www.w3schools.com/css/css_inline-block.asp
  • Web에서는 상대경로 사용해야함
    • ./ 현재폴더
    • ../부모폴더
    • ./../: 현재폴더의 상위폴더, 즉 상위폴더

 

jQuery

1) 선택자

2) 함수

ready(function): 문서가 로드되어 준비상태가 되었을 때 처리를 위한 함수

 

 

var obj=new jQuery(document);
obj.ready(testFun);
function testFun(){alert("hello");}

 

 

 

 

 

 new jQuery(document).ready(testFun);

 

$(document).ready(function(){alert("hello");});

 

 

즉, new jQuery( ) → $( )

 

3) 이벤트, 효과, 테마

 

pattern

    • 디렉토리 패턴: 각각 url로 요청
    • 확장자 패턴: *.do로 요청
      • @WebServlet(urlPatterns="*.do", initParams=@WebInitParam(name="configFile", value="/WEB-INF/commandURI.properties"))
    • front controller pattern: 모든 요청을 특정 서블릿이 받아서 실제 controller에 전달해줌
      • handler mapping
        • @WebServlet(urlPatterns="*.do", initParams=@WebInitParam(name="configFile", value="/WEB-INF/commandURI.properties"))
        • servlet init() method에서 파랑이 Properties를 불러와서 아래와 같이 request별 handler객체를 직접 생성하는 방법으로 handlerMapping함
     HashMap<String, Object> commandMap = new HashMap<String, Object>();
    Iterator<Object> keyIter=propertiesFile.keySet().iterator();
    while(keyIter.hasNext()){
    Class<?> handlerCalss=Class.forName(propertiesFile.getProperty((String)keyIter.next()));
    Object handlerInstance=handlerCalss.newInstance();
    commandMap.put((String)keyIter.next(), handlerInstance);
    
      • 전달받은 view path를 forward하는 방법
RequestDispatcher rd=request.getRequestDispatcher(viewPath); //viewPath="/WEB-INF/board/writeOK.jsp"
rd.forward(request, response);

 

JSP: 결국은 html +javascript로 변환되는 것 (JSP > Servlet > html+javascript)

  • encoding
    • html을 완전히 그대로 쓰면 한글 encoding이 깨짐
    • 최소한 아래 1줄은 추가해줘야 한글 UTF-8 처리가능함
    • <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    • 위 1줄 없이<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">이거만 쓰면 한글 깨짐
  • 톰캣에 의해 생성된 객체 request, response, session등을 서블릿과 공유한다, 그래서 request에 setParameter하면 jsp에서도 접근가능 
    • Controller(servlet)가 View(JSP)에게 model을 전달하는 방법이 바로 이것!
    • request.setAttribute("writeResult", writeResult);로 세팅하면, JSP에서 ${writeResult}로 사용가능
  • JSP에서 html comment <!-- --> 이거 안에 jsp syntax error있어도 에러남, <!-- -->안에 있어도 컴파일에러가 나며 컴파일에러는 무조건 잡아야 실행에러안남, syntax error 안고치고 주석처리하려면 태그내에서<% %> 주석을 써야함
  • EL(Expression Language) 
    • ${}이렇게 생긴거 
    • ${root} root 선언 빼먹어도 syntax error(compile error)안나고 단지 html로 변환될 때 empty string이 됨, 실행시 syntax error는 어디가 잘못인지 알려주지만 위치를 알려주지만, 변수명 잘못 쓰거나 한건은 체크가 안되고 html로 변환된 소스를 참고하여 비교해야 하므로 주의를 요함
  • JSTL
    • Java를 tag처럼 쓰게해줌
    •  
    • <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>  
      • <c:if test='${writeResult==1}'>
      • <c:forEach var="board" items="${boardList}">
      •   
    • <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 
      • <fmt:formatDate value="${board.writeDate}" type="both"/>

 

myBatis 참고:http://www.mybatis.org/mybatis-3/ko/

  • List<E> org.apache.ibatis.session.SqlSession.selectList(String arg0, Object arg1, RowBounds arg2)
  • Map<K, V> org.apache.ibatis.session.SqlSession.selectMap(String arg0, Object arg1, String arg2, RowBounds arg3)
  • T org.apache.ibatis.session.SqlSession.selectOne(String arg0, Object arg1)
  • void org.apache.ibatis.session.SqlSession.select(String arg0, Object arg1, RowBounds arg2, ResultHandler arg3)
  •  
  • input: parameterType, 
  • out: resultType, resultMap (DB 컬럼과 DTO/VO의 property변수명과 일치하면 resultType을 쓰고 아니면 매핑값을 지정해놓고 resultMap을 써야함)
  • session.commit(); 해주는 거 잊지말자!!

 

반응형

'etc' 카테고리의 다른 글

504 gateway time-out 에러 해결방법  (0) 2022.09.08
proxy/reverse proxy, web server, load balancer 개념  (0) 2022.09.08
character encoding  (0) 2022.07.11
app-ads.txt  (0) 2022.05.04
헷갈리는 것들  (0) 2019.03.15

+ Recent posts