아래처럼 한번에 테스트하니깐 속이 편하다. 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 한글깨짐
[카테고리:] Spring
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 사용하기
PDF 파일 처리 – JPG>PDF, PDF+PDF, 비밀번호 주입
import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; import com.itextpdf.text.Image; import com.itextpdf.text.PageSize; import com.itextpdf.text.pdf.PdfContentByte; import com.itextpdf.text.pdf.PdfImportedPage; import com.itextpdf.text.pdf.PdfReader; import com.itextpdf.text.pdf.PdfStamper; import com.itextpdf.text.pdf.PdfWriter; public class PdfUtils { private static final Logger logger = LoggerFactory.getLogger(PdfUtils.class); /** * PDF파일에 비밀번호를 주입한다. * @Param input … 계속 읽기 PDF 파일 처리 – JPG>PDF, PDF+PDF, 비밀번호 주입
POI 배경색상 표
POI에서 배경색상 지정할 때 아래 코드를 참고할 수 있겠다. CellStyle cs = workbook.createCellStyle();cs.setFillForegroundColor(HSSFColor.AQUA.index);cs.setFillPattern(CellStyle.SOLID_FOREGROUND); 색감순 WHITE LEMON_CHIFFON LIGHT_YELLOW YELLOW GOLD LIGHT_ORANGE ORANGE TAN LIGHT_GREEN BRIGHT_GREEN LIME GREEN DARK_YELLOW OLIVE_GREEN DARK_GREEN SEA_GREEN TEAL AQUA LIGHT_TURQUOISE TURQUOISE SKY_BLUE ROYAL_BLUE LIGHT_BLUE BLUE DARK_BLUE DARK_TEAL INDIGO BLUE_GREY PALE_BLUE LIGHT_CORNFLOWER_BLUE CORNFLOWER_BLUE LAVENDER ORCHID VIOLET PLUM MAROON CORAL ROSE PINK RED BROWN … 계속 읽기 POI 배경색상 표
POI 간단 사용법
//간단 엑셀변환 및 스트리밍 다운로드 @RequestMapping(value=”/toExcelNew.do”, method=RequestMethod.POST) public void toExcelNew(HttpServletRequest req, HttpServletResponse res) throws Exception { //엑셀 POI 객체 생성(wookbook → sheet → row → cell) //Keep 100 rows memory, exceeding rows will be flushed to disk SXSSFWorkbook workbook = new SXSSFWorkbook(100); //아래 처럼 해주면 새로운 시트가 생성됨 Sheet sheet = workbook.createSheet(“엑셀시트명”); //가로 3, 세로 … 계속 읽기 POI 간단 사용법
@Autowired private static SqlSession sqlSession
@Autowired private static SqlSession sqlSession이것이 static으로 할 경우 sqlSession이 Null이 될 수 있다.해결방법은 이렇다. private static SqlSession sqlSession; @Autowiredprivate void setSqlSession(SqlSession sqlSession){ this.sqlSession = sqlSession; } static 변수로 선언만 해주고, set메써드를 만들어 @Autowired를 걸어 준다.
글쓰기 Spring properties 사용방법
프러퍼티 파일 생성 먼저 아래와 같이 properties 파일을 만들어 주자 /WEB-INF/spring/properties/aabooSite-local.properties 다음 문장을 추가해보자 db.url = 127.0.0.1 db.username = aaboo db.password = !@!dsfsdf23432131a value1 = 12345 value2 = abcdef환경설정 구성(이클립스에서) 1) servlet-context.xml 에서 아래 내용 추가 /WEB-INF/spring/properties/aabooSite-${spring.profiles.active}.properties 2) 네임스페이스에 context 추가 servlet-context.xml 파일에서 하단에 Namespaces 탭으로 들어가서 context 체크하고 저장실행환경에서 spring.profiles.active 추가 Server 창에서 해당 … 계속 읽기 글쓰기 Spring properties 사용방법
Mybatis 쿼리를 바인딩된 String으로 가져오는 방법
마이바티스에서 수행되어 만들어진 쿼리를 추출하고 싶을 때 사용합니다. @Autowired SqlSession sqlSession 을 사용합니다. 1. Mapper.xml 에 쿼리가 아래와 같다고 가정하고 <select id="selectTest"> select * from test where idx1 = #{param.idx1} and idx2 = #{param.idx2} and userid = #{param.session.userid} </select> 2. 파라미터를 HashMap<String, Object> 형식일 경우 (기본적으로 모두 String형으로 할랍니다 "") //인터페이스 샘플입니다. 아래와 같다고 가정하고 … 계속 읽기 Mybatis 쿼리를 바인딩된 String으로 가져오는 방법
이클립스 단축키 대소문자 변환
단축키 설정하러 가기Window > Preferences > General > Keys 대문자 변환 : Ctrl + Shift + x 소문자 변환 : Ctrl + Shift + y 현재커서 줄/선택영역 줄 위치변경 : Alt + ↑ / Alt + ↓ 현재커서 줄/선택영역 줄 위로/아래로 복사하기 : Alt + Shift + ↑ / Alt + Shift + ↓ 세로편집모드(열모드/Toggle … 계속 읽기 이클립스 단축키 대소문자 변환