Spring MVC: CharacterEncodingFilter

I was having a look at the CharacterEncodingFilter provided by Spring MVC. I was wondering why it was only possible to set the response encoding when the request encoding was forced to the given encoding? Why not be able to set a default response encoding if nothing is specified in the accept header fields? Or if no encoding was present in the request?

The code:

protected void doFilterInternal(
  HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
  throws ServletException, IOException {
  if (this.encoding != null && (this.forceEncoding 
      || request.getCharacterEncoding() == null)) {
    if (this.forceEncoding) {
  filterChain.doFilter(request, response);

I found this as reference, but did not understand what it meant: https://jira.springsource.org/browse/SPR-3328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel

I posted this question on Stackoverflow. Let's see if somebody has an idea:

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Leave a Reply