Aarya Linga Reddy
Aarya Linga Reddy

Reputation: 25

Unable to print JSP from spring controller but result is printing in console

[code]

@Controller

public class AWSCostAndUsageClientController {

@Autowired
AWSCostAndExplorerService costExplorerService;

@RequestMapping("/aws")
public String cost(Model model) throws JsonProcessingException {

    List<ResultByTime> obj = costExplorerService.costUsage();


    ObjectWriter writer = new ObjectMapper().writer().withDefaultPrettyPrinter();
    String json = writer.writeValueAsString(obj);
    System.out.println(json);

    model.addAttribute("costData", json);
    return "cost";
}

}

WARN 3864 --- [nio-8081-exec-1] o.s.w.s.r.ResourceHttpRequestHandler : Path with "WEB-INF" or "META-INF": [WEB-INF/view/cost.jsp]

I'am unable to print jsp. In the browser it is printing

Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Tue Feb 26 12:17:40 IST 2019 There was an unexpected error (type=Not Found, status=404). No message available

I'am developing spring boot project.

application.properties

spring.mvc.view.prefix=/WEB-INF/view/

spring.mvc.view.suffix=.jsp

Upvotes: 0

Views: 828

Answers (1)

Aarya Linga Reddy
Aarya Linga Reddy

Reputation: 25

My issue has been solved. I have to add the dependencies of jasper and jstl.

<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>

Upvotes: 2

Related Questions