crear servlet url-patrón con "/"
He creado un servlet llamado MainContent. y tengo tal mapeo
<servlet>
<display-name>MainContent</display-name>
<servlet-name>MainContent</servlet-name>
<servlet-class>ge.test.servlet.MainContent</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MainContent</servlet-name>
<url-pattern>/main</url-pattern>
</servlet-mapping>
Entonces, cuando voy al enlace:// localhost: 8080 / MyAppl / main Entro en el método doGet () de servlets. Entonces creo RequestDispatcher hacia el index.jsp.
¡Todo funciona!
RequestDispatcher rd = context.getRequestDispatcher("/index.jsp?language="+ lang);
rd.forward(request, response);
¡Todo funciona!
Pregunta:
Ahora necesito cambiar el patrón de url. Necesito algo así: cuando entro a lalocalhost: 8080 / MyAppl / Necesito ser redirigido a mi servlet. Así que creo algo así:
<url-pattern>/</url-pattern>
ok funciona Estoy redirigido al servlet.pero Algo malo sucedió aquí. cuando Servlet creó RequestDispatcher adelante, no había imágenes y css en mi index.jsp. cuando veo en la consola de firebug, he visto que los errores:
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:8080/MyApp/font/font_big.css". localhost/:15
Resource interpreted as Image but transferred with MIME type text/html: "http://localhost:8080/MyApp/IMG/company.gif".
¿Cómo puedo arreglar eso?