ssm의 필터 방법은 깨진 포스트 문제를 해결합니다.

왜곡 된 문제 설명 게시 :
프런트 엔드 페이지에 데이터를 입력하면 마지막으로 저장된 데이터가 왜곡되어 나타납니다.

솔루션 : web.xml에 필터 구성 추가

<!--解决post 乱码问题的过滤器-->
    <filter>
        <filter-name>characterEncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>utf-8</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>characterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

필터 코드 스 니펫의 배치에주의해야합니다.
여기에 사진 설명 삽입

배치 위치가 잘못된 경우 라벨 배치 순서를 묻는 메시지가 표시되고 프롬프트 주문 정보에 따라 필터가 배치됩니다.
레이블 순서는 다음과 같습니다.
(icon?, display-name?, description?, distributable?, context-param *, filter *, filter-mapping *, listener *, servlet *, servlet-mapping *, session-config? , mime- mapping *, welcome-file-list?, error-page *, taglib *, resource-env-ref *, resource-ref *, security-constraint *, login-config?, security-role *, env- 항목 *, ejb-ref *, ejb-local-ref *) "

추천

출처blog.csdn.net/Hambur_/article/details/110819758