I have a Spring Boot project and I'm trying to make the following call in a JSP file:
The tags folder is in -
\src\main\resources\WEB-INF\tags
The JSP files folder is in -
\src\main\resources\META-INF\resources\WEB-INF\jsp
I also defined the application.properties file to include:
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
If I try to put the tags folder in any other classpath than Intellij is showing an error that It cannot identify the call in the editor.
The JSP page is presented properly if I remove the taglib call.
My pom.xml is of course has these dependencies:
org.springframework.boot
spring-boot-starter-web
1.5.4.RELEASE
spring-boot-starter-tomcat
org.springframework.boot
org.apache.tomcat.embed
tomcat-embed-jasper
8.5.15
javax.servlet
servlet-api
3.0-alpha-1
javax.servlet
jstl
1.2
I get the following error:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing
this as a fallback.
Sun Jun 25 16:12:47 IDT 2017 There was an unexpected error
(type=Internal Server Error, status=500). /WEB-INF/jsp/main.jsp
(line: [11], column: [4]) No tag [utils] defined in tag library
imported with prefix [tagz]
I think It has to do with configuration of static files in Spring Boot but I tried to add
spring.resources.static-
locations=classpath:/resources/static/,classpath:/resources/,classpath:/static/,classpath:/public/,classpath:/WEB-INF/tags/,classpath:/WEB-INF/
spring.mvc.static-path-pattern=/resources/**
Nothing seems to work.
I should mention that these taglibs are working properly!
Any help?
解决方案
So after a lot of trail and error I now put all my JSP files inside of path:
webapp/WEB-INF/jsp
Tags files inside of:
webapp/WEB-INF/tags
And Tlds files inside of:
webapp/WEB-INF/tld
When you call the tag/tld files you inside of the JSPs you need to refer them to relative path e.g:
You will also need to define a Facet in project structure. If you don't have it define that means that you need to generate it by adding "web framework" to your project. It will generate web.xml and you need to put it under webapp/WEB-INF and edit it in project Facets manaully.
Hope this will help anyone who sees this post.