2014-06-10 2 views
0

힌디어 단어/문자를 데이터베이스에 삽입하는 방법 jsp에서 힌디어 단어를 입력하는 동안 컨트롤러에서 힌디어 단어를 입력하는 중입니다. 나는 UTF-8 & UTF-16을 사용했기 때문에 인코딩을 멈출 필요가 있지만 인코딩도되고있다. 나는 힌디어 형식을 DB에 저장해야한다. 다음은 스 니펫 plz이 나를 도와 준다.데이터베이스에 힌디어 (다른 언어) 문자를 삽입하는 방법

//controller(Sample.java) 

@RequestMapping(value = "/createContentforCp", method = RequestMethod.POST,consumes="application/x-www-form-urlencoded;charset=UTF-16") 
    public ModelAndView createContentForCp(
      HttpServletRequest request, 
      HttpServletResponse response, 
      @RequestParam("desc") String desc)throws Exception{ 
     request.setCharacterEncoding("UTF-16"); 
System.out.println("description================"+desc) 
ModelAndView modelView = new ModelAndView("create-content-meta"); 
return modelview; 
} 

o/p: 
description====================�र��त�र� enter code here 

While am displaying that description in console it is getting encoded and saving the same in database. 
는 는

답변

0

당신은 URLDecoder.decode를 사용해보십시오()URLEncoder.encode() java.net에서 클래스 수 : 디코드() 응답을 제공을 사용하는 동안

URLDecoder.decode("String with Hindi characters", "UTF-8"); 
URLEncoder.encode("String with Hindi characters", "UTF-8"); 
+0

안녕하세요, 위의 사용 à¤? ¤¤ª? ¤? ¾와 encode()를 사용하여 응답을 형식으로 가져 오는 경우 % C3 % A0 % C2 % A4 % C2 % 95 % C3 % A0 % C2 % A4 % C2 % AA % C3 % A0 % C2 % A4 % C2 % A1 % C3 % A0 % C2 % A4 % C2 % BE. 그러나 힌디어 문자로 표시되지 않습니다. – user3440746

관련 문제