如何将印地语单词/字符插入数据库..从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 :(得分:0)
您可以尝试使用java.net中的 URLDecoder.decode()和 URLEncoder.encode()类:
URLDecoder.decode("String with Hindi characters", "UTF-8");
URLEncoder.encode("String with Hindi characters", "UTF-8");