Reputation: 327
I am using JSP as a view resolver in spring-mvc. Will those pages be converted to servlets in tomcat?
If so, is the same applicable for other views like Velocity, Thymeleaf etc.? Please explain how it works.
Upvotes: 1
Views: 683
Reputation: 16158
Will JSP converted as a servlet code if i use spring?
Yes. If you use JSP anywhere* it will be converted to Servlet.
* - For Java EE Applications which uses Servlet containers.
I don't about Velocity ,thymleaf,etc.
.
Upvotes: 2
Reputation: 47665
Yes, a JSP is always converted to a servlet, that is how JSP files work.
The same is not always true in other view/templates engine. For example, Velocity is a Java-based template engine, velocity templates are parsed, but it does not depend on having a servlet engine.
Regarding to Spring, it has view resolvers for a lot of different technologies, so you have a layer of abstraction and don't have to worry about how the views are internally translated to render your model.
Upvotes: 3
Reputation: 2443
JSP, Velocity, Freemarker etc. in respect to Spring MVC are template libraries. For example, the user make an HTTP request to a specified URL. This URL is mapped to a Spring controller. The controller will build an instance of a model and return the view and the model. Then Spring will use the view (i.e. a jsp file) and convert it to HTML using the model. The user gets the resulting HTML.
More about Spring MVC and templates here http://static.springsource.org/spring/docs/2.0.x/reference/view.html
Upvotes: 1