编程语言
首页 > 编程语言> > Java--前端传到后台中文乱码问题

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,--,bookname,modelAndView,乱码,book,books,new,ModelAndView
来源: https://www.cnblogs.com/lihp-java/p/15625948.html