I can't get the values added to the model in jsp dispalyed. I have tried with everything and and checked all answers on stackoverflow, but nothing helps.
To save your time, I paste a part of code:
My pom.xml
:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.5.RELEASE</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
and my java config code is :
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
and
@EnableWebMvc
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
@Bean
public InternalResourceViewResolver getViewResolver(){
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/WEB-INF/jsp/");
viewResolver.setSuffix(".jsp");
return viewResolver;
}
}
my controller is :
@Controller
@RequestMapping(value = "workorder")
public class WorkOrderController {
@RequestMapping(value = "/toProviewPage", method = RequestMethod.GET)
public ModelAndView toPreview(){
WorkOrderVo workOrderVo = new WorkOrderVo();
workOrderVo.setId(1);
workOrderVo.setName("xxx");
workOrderVo.setPriority(1);
workOrderVo.setDetail("xxxx");
return new ModelAndView("workOrderPreview", "workOrderVo", workOrderVo);
}
}
my jsp file is :
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<div class="form-group">
<label for="detail" class="col-sm-2 control-label">Detail</label>
<div class="col-sm-10">
<textarea class="form-control" rows="5" id="detail" name="detail" value="${workOrderVo.dreadonly="true"></textarea>
</div>
</div>
but spring boot doesn't resloved is as a jsp file, and display all the html code is the Browser.
Where I write errors?