jsp显示的数据库数据是乱码
package com.imooc.oa.global; import javax.servlet.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; public class EncodingFilter implements Filter { private String encoding="utf-8"; public void init(FilterConfig filterConfig) throws ServletException { encoding=filterConfig.getInitParameter("encoding"); } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest request=(HttpServletRequest)servletRequest; HttpServletResponse response=(HttpServletResponse)servletResponse; request.setCharacterEncoding(encoding); response.setCharacterEncoding(encoding); filterChain.doFilter(request,response); } public void destroy() { } }
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <!--编码过滤器--> <filter> <filter-name>encoding</filter-name> <filter-class>com.imooc.oa.global.EncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>utf-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encoding</filter-name> <url-pattern>/</url-pattern> </filter-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>/assets/*</url-pattern> <url-pattern>/js/*</url-pattern> <url-pattern>/vendor/*</url-pattern> <url-pattern>*.js</url-pattern> <url-pattern>*.jpg</url-pattern> <url-pattern>*.gif</url-pattern> <url-pattern>*.css</url-pattern> <url-pattern>*.png</url-pattern> </servlet-mapping> <servlet> <servlet-name>springmvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-web.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springmvc</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <!DOCTYPE html> <html> <!-- Mirrored from admindesigns.com/demos/absolute/1.1/admin_forms-validation.html by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 06 Aug 2015 02:56:15 GMT --> <head> <!-- Meta, title, CSS, favicons, etc. --> <meta charset="utf-8"> <title> 爱慕课OA--欢迎使用爱慕课OA系统 </title> <link rel="stylesheet" type="text/css" href="/assets/skin/default_skin/css/theme.css"> <link rel="stylesheet" type="text/css" href="/assets/admin-tools/admin-forms/css/admin-forms.css"> <link rel="shortcut icon" href="/assets/img/favicon.ico"> </head> <body class="admin-validation-page" data-spy="scroll" data-target="#nav-spy" data-offset="200"> <div id="main"> <header class="navbar navbar-fixed-top navbar-shadow"> <div class="navbar-branding"> <a class="navbar-brand" href="dashboard.html"> <b>爱慕课</b>OA </a> <span id="toggle_sidemenu_l" class="ad ad-lines"></span> </div> <ul class="nav navbar-nav navbar-right"> <li class="dropdown menu-merge"> <a href="#" class="dropdown-toggle fw600 p15" data-toggle="dropdown"> <img src="/assets/img/avatars/5.jpg" alt="avatar" class="mw30 br64"> <span class="hidden-xs pl15"> ${sessionScope.employee.name} </span> <span class="caret caret-tp hidden-xs"></span> </a> <ul class="dropdown-menu list-group dropdown-persist w250" role="menu"> <li class="list-group-item"> <a href="/self" class="animated animated-short fadeInUp"> <span class="fa fa-user"></span> 个人信息 <span class="label label-warning"></span> </a> </li> <li class="list-group-item"> <a href="/to_change_password" class="animated animated-short fadeInUp"> <span class="fa fa-gear"></span> 设置密码 </a> </li> <li class="dropdown-footer"> <a href="/quit" class=""> <span class="fa fa-power-off pr5"></span> 退出 </a> </li> </ul> </li> </ul> </header> <aside id="sidebar_left" class="nano nano-light affix"> <div class="sidebar-left-content nano-content"> <header class="sidebar-header"> <div class="sidebar-widget author-widget"> <div class="media"> <a class="media-left" href="#"> <img src="assets/img/avatars/3.jpg" class="img-responsive"> </a> <div class="media-body"> <div class="media-author">${sessionScope.employee.name}---${sessionScope.employee.post}</div> <div class="media-links"> <a href="/quit">退出</a> </div> </div> </div> </div> <div class="sidebar-widget search-widget hidden"> <div class="input-group"> <span class="input-group-addon"> <i class="fa fa-search"></i> </span> <input type="text" id="sidebar-search" class="form-control" placeholder="Search..."> </div> </div> </header> <ul class="nav sidebar-menu"> <li class="sidebar-label pt20">日常管理</li> <li> <a href="/claim_voucher/deal"> <span class="glyphicon glyphicon-book"></span> <span class="sidebar-title">待处理报销单</span> <span class="sidebar-title-tray"> <span class="label label-xs bg-primary">New</span> </span> </a> </li> <li class="active"> <a href="/claim_voucher/self"> <span class="glyphicon glyphicon-home"></span> <span class="sidebar-title">个人报销单</span> </a> </li> <li> <a href="/claim_voucher/to_add"> <span class="fa fa-calendar"></span> <span class="sidebar-title">填写报销单</span> </a> </li> <li class="sidebar-label pt15">基础信息管理</li> <li> <a class="accordion-toggle" href="#"> <span class="glyphicon glyphicon-check"></span> <span class="sidebar-title">员工管理</span> <span class="caret"></span> </a> <ul class="nav sub-nav"> <li> <a href="/employee/list"> <span class="glyphicon glyphicon-calendar"></span> 所有员工 </a> </li> <li class="active"> <a href="/employee/to_add"> <span class="glyphicon glyphicon-check"></span> 添加员工 </a> </li> </ul> </li> <li> <a class="accordion-toggle" href="#"> <span class="fa fa-columns"></span> <span class="sidebar-title">部门管理</span> <span class="caret"></span> </a> <ul class="nav sub-nav"> <li> <a href="/department/list"> <span class="glyphicon glyphicon-calendar"></span> 所有部门 </a> </li> <li class="active"> <a href="/department/to_add"> <span class="glyphicon glyphicon-check"></span> 添加部门 </a> </li> </ul> </li> </ul> <div class="sidebar-toggle-mini"> <a href="#"> <span class="fa fa-sign-out"></span> </a> </div> </div> </aside> <section id="content_wrapper">
15
收起
正在回答 回答被采纳积分+1
3回答
4. SSM到Spring Boot入门与综合实战
- 参与学习 人
- 提交作业 323 份
- 解答问题 8263 个
本阶段将带你学习主流框架SSM,以及SpringBoot ,打通成为Java工程师的最后一公里!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星