본문 바로가기

Java11

[JAVA] Enumeration 세션값 출력 Enumeration을 사용해 세션에 등록한 모든 값을 출력 Enumeration attributes = request.getSession().getAttributeNames(); while (attributes.hasMoreElements()) { String attribute = (String) attributes.nextElement(); System.err.println(attribute+" : "+request.getSession().getAttribute(attribute)); } 2022. 2. 25.
[JAVA] String 문자열 따옴표(") 넣기 자바에서 문자열에 " "를 사용하기 때문에 따옴표를 그냥 넣으면 아래와 같이 오류가 보인다! 그래서 따옴표를 넣을때 \" 넣으면 된다. - TEST String test = "A: \"안녕하세요!\"... B: \"안녕!\""; System.out.println(test); - 결과 2022. 2. 22.
[SPRING SECURITY] BCryptPasswordEncoder 비밀번호 암호화 테스트 환경: 전자정부프레임워크 3.7 / SPRING 4.2.4 1. pom.xml 에 spring security dependency 추가 org.springframework.security spring-security-web 4.2.3.RELEASE org.springframework.security spring-security-core 4.2.3.RELEASE org.springframework.security spring-security-config 4.2.3.RELEASE 2. 암호화를 위해 context.xml 에 bean 객체 생성 3. @Autowired BCryptPasswordEncoder @Autowired BCryptPasswordEncoder passwordEncoder; 4. .. 2022. 2. 4.
[JAVA] Random 사용하여 임시 비밀번호 생성 java.util.Random을 사용하여 간단하게 임시 비밀번호를 생성해보자! - 코드 public static String tempPassword(int leng){ int index = 0; char[] charSet = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',.. 2022. 1. 14.
[JAVA] 파일 ZIP 압축 및 다운로드 간단한 파일 압축 및 다운로드 코드 /* 다운로드 Zip */ @RequestMapping("/downloadZip.do") public void downloadZip(@RequestParam Map paramMap, HttpSession session, HttpServletResponse response) throws Exception { //압축할 파일 String[] fileList = {"C:/Users/kyung/Desktop/테스트첨부파일/TTTTT.txt" ,"C:/Users/kyung/Desktop/테스트첨부파일/test.PNG" ,"C:/Users/kyung/Desktop/테스트첨부파일/TESTPDF.pdf"}; //생성되는 zip 파일명 String fileName ="makeZipFi.. 2022. 1. 12.
반응형