title: Spring MVC: CharacterEncodingFilter; why only set response encoding by force?
body: <p>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?</p>
  
  <p>The code:</p>
  
  <pre><code>@Override
  protected void doFilterInternal(
    HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
    throws ServletException, IOException {
  
    if (this.encoding != null &amp;&amp; (this.forceEncoding 
        || request.getCharacterEncoding() == null)) {
  
      request.setCharacterEncoding(this.encoding);
      if (this.forceEncoding) {
        response.setCharacterEncoding(this.encoding);
      }
    }
    filterChain.doFilter(request, response);
  }
  </code></pre>
  
  <p>I found this as reference
  <a href="https://jira.springsource.org/browse/SPR-3328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel" rel="noreferrer">https://jira.springsource.org/browse/SPR-3328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel</a>
  stating that the response encoding can only be set when the request encoding is forcibly set. Why?</p>
  
  <p>Thanks in advance,
  Martin</p>