Hi,
I am a newbie to Spring. I am working with a very basic application. The workflow is
1) CustomerDtls.html page collecting customer data i.e. name, email address, phone #
2.) on submitting the data, save it to the in memory database
I am
testing the above with apache-tomcat-8.0.18 server with exploded directory deployment. Deployment no issues.
Below is my deployment Structure
<CustomerService>
------------------------META-INF
-------------------------static
----------------------------------CustomerDtls.html
----------------------------------ThankYou.html
-------------------------WEB-INF
------------------------------------classes
------------------------------------lib
------------------------------------spring
------------------------------------views
------------------------------------web.xml
in the web-inf/spring/servlet.context.xml i have the following configuration
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Handles HTTP GET requests for /static/** by efficiently serving up static resources in the ${webappRoot}/static directory -->
<resources mapping="/static/**" location="/static/" />
<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
I have a CustomerDtlsController.java as below
When i go to the browser and type
http://localhost:8080/CustomerService/CustomerDtls.html, it does not load the .html page, workflow starts with CustomerDtlsController.customerFormSubmit() and displays an 404 message saying requested resource /views/static/ThankYou.html.jsp is not available.
i changed the static resource mapping from
<resources mapping="
/static/**" location="/static/" />
to
<resources mapping="
/*.html**" location="/static/" />
After doing the above change i am able to atleast load the ThankYou.html as
http://localhost:8080/CustomerService/ThankYou.html, else would get 404 error message.
Below is what i want to know:
1.) CustomerDtls.html is a static file and i want to load it without dispatcher
servlet routing it to CustomerDtlsController, on submit of the details the controller needs to be approached.
2.) If the view returned from controller is a plain .html file how do we configure it, so that view controller knows to look in WEB_ROOT/static folder and not WEB_INF/VIEWS
Please help me.
Best Regards,
REshma