<%@ page import="com.myweb.utils.Utils" %> /*이 부분은 콤마(,)로 여러개를 추가할 수 있다.*/ <%@ page contentType="text/html; charset=UTF-8" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="ax" uri="http://axisj.com/axu4j" %>
크로스사이트스크립트 필터(XSS)
일번적으로 <를 < 로, 또는 >를 > 로만 잡아주면 되지만,부득이한 상황으로 그렇게 못할 경우 아래 코드를 사용한다. iframe을 i_rame으로 2번째 문자를 _로 바꿔주는 형식이다. package com.mySite.utils; public class XssUtils { public static final String[] ignoreKeyword = new String[]{ // "<" // ,">" "\"" // ,"%22" ,"'" // ,"%27" // ,"%" // ,"&" ,"%00" // ,"\\(" … 계속 읽기 크로스사이트스크립트 필터(XSS)
JAVA 한글깨짐
아래처럼 한번에 테스트하니깐 속이 편하다. String title = "한글이 깨져서 뚁땅해~"; System.out.println("euc-kr → utf-8: " + new String(title.getBytes("euc-kr"), "utf-8")); System.out.println("euc-kr → ksc5601: " + new String(title.getBytes("euc-kr"), "ksc5601")); System.out.println("euc-kr → x-windows-949: " + new String(title.getBytes("euc-kr"), "x-windows-949")); System.out.println("euc-kr → iso-8859-1: " + new String(title.getBytes("euc-kr"), "iso-8859-1")); System.out.println("utf-8 → euc-kr: " + new String(title.getBytes("utf-8"), "euc-kr")); System.out.println("utf-8 → ksc5601: " … 계속 읽기 JAVA 한글깨짐
crontab
참조: https://jdm.kr/blog/2 1. 작성 $ crontab -e 2. 보기 $ crontab -l 3. 전체 삭제 $ crontab -r 4. 실행주기 설정(요일: 0,7==일요일) * * * * *분(0-59) 시간(0-23) 일(1-31) 월(1-12) 요일(0-7) 5. 예제 # 매분 test.sh 실행* * * * * /home/script/test.sh # 매주 금요일 오전 5시 45분에 test.sh 를 실행45 5 * * 5 /home/script/test.sh # 매일 매시간 0분, 20분, 40분에 test.sh … 계속 읽기 crontab
JAVA 나눗셈 소수이하 표기(BigDecimal)
두 개의 인수 중 한개 이상이 double 이면 double로 리턴된다.double c = (double) 100 / 3; 아래는 소수자릿수를 원하는 만큼 보여주는 방식이다. 1. 첫번째 방법(리턴타입 Double) System.out.println(Math.round((c)*100)/(double) 100); //33.33System.out.println(Math.round((c)*1000)/(double) 1000); //33.333System.out.println(Math.round((c)*10000)/(double) 10000); //33.3333 2. 두번째 방법(리턴타입 String) System.out.println(String.format("%.2f", c)); //33.33System.out.println(String.format("%.3f", c)); //33.333System.out.println(String.format("%.4f", c)); //33.3333 3. Double, Float의 계산 오류 >> BigDecimal 사용 double d = … 계속 읽기 JAVA 나눗셈 소수이하 표기(BigDecimal)
JAVA에서 javascript 엔진 사용하기
import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public static void main(String[] agrgs){ ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); //javascript 엔진 불러오기 ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("js"); try { String value = scriptEngine.eval("(Math.round(1/3*10000)/10000).toFixed(4)").toString(); System.out.println(value); } catch (ScriptException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
현재 시간 밀리세컨드 millisecond 구하기
public String getCurrentTimeStamp() { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()); }
Window에서 command에서 curl 사용하기
참고 : https://m.blog.naver.com/javaking75/220776461230 curl 사이트에서 window 비트에 맞추어 zip 파일을 다운로드 받는다.https://curl.haxx.se/download.html curl-7.64.1.zip 1. 사용방법 : 아래위치로 압축푼 파일 이동 C:\curl-7.64.1-win64-mingw 2. 시스템 환경 변수에서 path 편집으로 들어가서 아래 내용 추가 C:\curl-7.64.1-win64-mingw\bin; 3. 사용예시 - Command 창 띄움 Window+R > cmd - 명령어 예시 curl http://test.aaboo.com/batch/merchantEmailAttachMaker?recvdate=20190415
외부 URL 이미지, html을 response
public void responseURLImage(HttpServletResponse res){ res.setStatus(200); res.setContentType("application/octet-stream"); String imageLocation = "https://www.aaboo.co.kr/img/aaboo.gif"; URL imgUrl = new URL(imageLocation); InputStream in = new BufferedInputStream(imgUrl.openStream()); OutputStream out = res.getOutputStream(); byte[] buf = new byte[1024]; int count = 0; while((count = in.read(buf)) >=0){ out.write(buf, 0, count); } out.close(); in.close(); } 위의 경우는 이미지파일이 다운받아진다. 브라우저에서 다운받는 대신, 링크를 이동할 경우 아래처럼 … 계속 읽기 외부 URL 이미지, html을 response
Spring properties 사용하기
1. 프러퍼티 파일 생성 먼저 아래와 같이 properties 파일을 만들어 주자 /WEB-INF/spring/properties/aabooSite-local.properties 다음 문장을 추가해보자 db.url = 127.0.0.1 db.username = aaboo db.password = !@!dsfsdf23432131avalue1 = 12345 value2 = abcdef 2. 환경설정 구성(이클립스에서) 1) servlet-context.xml 에서 아래 내용 추가 <!-- 프로퍼티 파일 설정 --> <beans:bean id="properties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <beans:property name="locations"> <beans:list> <beans:value>/WEB-INF/spring/properties/aabooSite-${spring.profiles.active}.properties</beans:value> </beans:list> </beans:property> </beans:bean> <!-- 위의 … 계속 읽기 Spring properties 사용하기