Popup Static HTML page
I have configured dispatcher servlet as below
This is my view resolver
Now, i got a requirement to popup dynamic generated HTML page. My directory structure is as below.
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />
Now when i tried to open http://localhost:8084/myProject/docs/generatedHTML.html
> generated html
> all jsp pages
view resolver is looking for jsp page and return 404.
If i change url-pattern of dispatcher servlet it works. But as i have already implement the most of the project i don't want to change in the all controllers.
Is there any way in SPRING to bypass the view resolver and it will look for html? or any other solution?
One way of achieving your goal is to set the response type to "text/html" and then write the contents of your dynamically generated HTML file to response outputstream. By this way you can force the browser to render the generated HTML page
Thanks for the reply. I didn't understand exactly your solution.
My problem exactly is that when i tried to access HTML page
according to view resolver it tries to look HTML page at
but actually it is HTML and outside of WEB-INF. Hope it will help you to understand better.
If you are in a situation where in your dynamically generated HTML has to be shown as a response after some processing (request) then you can just read the contents of HTML file in your code into byte and write that into response's outputstream by setting the content type to "text/html". Some what like this in your controller
And If you are in a situation where in your end user will enter that URL to access the outside sitting 'generatedHTML.html' file then you can try to chain the view resolvers by setting 'order' property suitably. I hope this will solve the issue though I've never tried this approach nor have come across your situation. Here is the reference also this
public ModelAndView getHTMLFile(HttpServletRequest request, HttpServletResponse response)
byte arrFileContents = someManager.getHTMLFileContents();//You have read the file into an array of bytes
response.setContentType("text/html");//Browser will by default try to render the HTML page