Auto identify mime types in wildfly10

To confirm all UTF-8 characters added to the Servlet filter

servletResponse.setContentType("text/html; charset=" + "UTF-8");
servletRequest.setCharacterEncoding(servletResponse.getCharacterEncoding());

because of this, it sets the content type as "text \ html" for all file types, and for css also the browser refuses to load its css with an error in the browser as.

Resource interpreted as Stylesheet but transferred with MIME type text/html:

But the above works in jboss 6 I tried to install

<servlet-container name="default">
    <jsp-config mapped-file="false" development="true"/>
    <websockets/>
    <mime-mappings>
        <mime-mapping name="css" value="text/css"/>
        <mime-mapping name="msi" value="application/x-msi"/>
    </mime-mappings>
</servlet-container>

in standalone-full.xml, but this does not work. How to automatically identify file content types?

+4
source share
1 answer

Your servlet filter is really not the best answer for supporting all UTF-8 characters, as you have noticed, this choice is strange, but I will not discuss it because it is not your question.

, , - , text/html, url- .

, :

<filter>
   <filter-name>MyServletFilter<filter-name>
   <filter-class>[...]</filter-class>
   <init-param>
       [...]
   </init-param>
</filter>

<filter-mapping>
   <filter-name>MyServletFilter</filter-name>
   <url-pattern>*.jsp</url-pattern>
</filter-mapping>

, , text/html.

, http://myserver.com/myapp/myservlet/staticcontent/file.xls, .

+1

Source: https://habr.com/ru/post/1683428/


All Articles