1

May be this question has an answer already.But that is an accepted answer.Because it works in web servers only.

My web.xml will be ,

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>

I want to exclude the hello.html from the spring controller.

Also that thing should be work on all servers like tomcat,Jboss,websphere etc..

Is it possible ?Hope I will get a good solution.

Human Being
  • 8,269
  • 28
  • 93
  • 136

1 Answers1

1

How about just creating a new server-mapping point that points to the default servlet before the spring mapping?

<servlet-mapping>
    <servlet-name>Default</servlet-name>
    <url-pattern>hello.html</url-pattern>
</servlet-mapping>

Should work for tomcat but possibly it will work for other servers as well.

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263
sodik
  • 4,675
  • 2
  • 29
  • 47
  • Doesn't this *include* `hello.html` instead of excluding it? To the person flagging this answer, please comment and possibly vote down, but don't just flag because you dislike the answer. – Maarten Bodewes Dec 21 '13 at 15:17
  • he wanted to exclude `hello.html` from spring controller. This is achieved by "including" it to default servlet that just handle it as plain resource... what's wrong with that approach? – sodik Dec 21 '13 at 21:26
  • OK, did not see that. Reformatted in answer. Removed downvote. – Maarten Bodewes Dec 22 '13 at 03:32