本文主要是介绍Java--前端传到后台中文乱码问题,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
@RequestMapping("/querybook.html")
public ModelAndView queryBookDo1(HttpServletRequest request,@RequestParam("searchWord") String bookname , Book book) {
if(bookname!=null){
try{
bookname = new String(bookname.getBytes("ISO8859-1"),"UTF-8");
}catch (UnsupportedEncodingException e){
e.printStackTrace();
}
}
book.setName(bookname);
System.out.println("==========打印传参"+book.getName());
if (bookService.matchBook1(book)) {
ArrayList<Book> books = bookService.queryBook1(book);
ModelAndView modelAndView = new ModelAndView("admin_books");
modelAndView.addObject("books", books);
return modelAndView;
} else {
return new ModelAndView("admin_books", "error", "没有匹配的图书");
}
}
这篇关于Java--前端传到后台中文乱码问题的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!