前端JSP传来中文信息,却显示乱码:
前端代码:
<form action="${pageContext.request.contextPath }/nameupload.model" method="post" accept-charset="GBK" οnsubmit="document.charset='GBK';"> <h2>关键字检索</h2> 文件:<input type="text" name="uploadname"/><br/><br/> <input type="submit" value="检索"/> </form> 后端的接受代码: public ModelAndView nameUpload(HttpServletRequest request) throws Exception { //chinese de code ing problem String name = new String((request.getParameter("uploadname")).getBytes("ISO-8859-1"),"GBK"); System.out.println(name); textsearch texttest = new textsearch(); texttest.searchtext(request, name); return new ModelAndView("success"); }主要代码: String name = new String((request.getParameter("uploadname")).getBytes("ISO-8859-1"),"GBK"); 不确定解决所有人的问题。:)