java自定义标签文件路径,通过Spring Boot在JSP中使用自定义标签文件

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值