I am using HTML Filter to delete white spaces from out put of my jsp pages and servlets. I am learning JSP development with Spring MVC. So I am using filter mapping and error page with web.xml file and my web.xml codes are
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<error-page>
<error-code>404</error-code>
<location>/error404</location>
</error-page>
<filter>
<filter-name>whitespaceFilter</filter-name>
<filter-class>test.web.htmlminify.HTMLMinifyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>whitespaceFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
And I have three controllers with no methods but only returning pages which are
HomeController, TestController, Error404Controller
which has homePage(), testPage() and errorPage() method which are returning following ,
return "home";
return "test";
return "error";
And I do have one jsp file outside of WEB-INF folder named abc.jsp file.
So situation is that when I access localhost, localhost/abc.jsp, localhost/testpage and localhost/error404
the filter mapping is working, as when I see source code of html webpage in browser, there is not white space in it but when i try to access localhost/ashhjb or localhost/kjdhvid/sdvfdjiu anything like that, filter mapping is not working. It means I am seeing white spaces in html pages when servlet is calling 'error' page instead of direct error controller method in browser. localhost/error404 is direct call to error page servlet. So can anyone help me and suggest me what should I do?
Thanx for helping in advance.
Aucun commentaire:
Enregistrer un commentaire