0
votes

I use an application.yml based spring-boot for a project. As example project I used https://github.com/ghillert/spring-boot-jsp-demo/blob/master/jsp-demo-tomcat/src/main/resources/application.properties works very good so far.

I was so brave to change the settings from application.properties

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

to

spring.mvc.view.prefix: /WEB-INF/jsp/
spring.mvc.view.suffix: .jsp

Unfortunaetly after changing the properties the example is not working anymore. Is it possible to configure the given properties in the way I do in application.yml? Or how do I configure the settings otherwise?

3
why cant you use .yml instead of .properties?ScanQR
The project already has migrated to use yml files :-( And its working only for the jsp part notEhmKah a.k.a. Michael Krauße
@TechBreak isn't that exactly the thing OP is trying to do?eis
@eis i am confused from name of file. application.propertiesScanQR
@TechBreak - in first post I had a spelling error.EhmKah a.k.a. Michael Krauße

3 Answers

2
votes
  1. With Spring-Boot 1.3 the property name changed from spring.view.prefix to spring.mvc.view.prefix. Make sure you are using the right name.

  2. Also make sure that the dependency to org.apache.tomcat.embed:tomcat-embed-jasper is not marked as provided when you are in Spring-Boot standalone mode. Otherwise the JspServlet will not be registered as a Servlet-Mapping in TomcatEmbeddedServletContainerFactory as it's not in the classpath.

2
votes

You need to create application.yml file in your src/main/resources folder (you have got application.properties at the moment in your project, which needs to be deleted), it should be as shown below:

spring: 
       mvc:
           view:
                prefix: /WEB-INF/jsp/
                suffix: .jsp

P.S.: Make sure that the indentation is exactly same, otherwise if you use tabs, you will get the exception like 'found character '\t(TAB)' that cannot start any token. (Do not use \t(TAB) for indentation)'

0
votes

I think you should be using springs capabilities here,

i.e. YamlPropertiesFactoryBean

The YamlPropertiesFactoryBean will load YAML as Properties.

Also check this link if that helps,

How to use YamlPropertiesFactoryBean to load YAML files using Spring Framework 4.1?