简体   繁体   English

如何在Eclipse或IntelijIdea中自动将taglib描述符添加到jsp?

[英]How to automatically add taglib descriptor to jsp in Eclipse or IntelijIdea?

I want to search in jsp files and find the files that use taglibs but doesn't have taglib descriptor, for example: 我想在jsp文件中搜索并找到使用taglibs但没有taglib描述符的文件,例如:

Test.jsp Test.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="true"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Test page</title>
</head>
<body>
    <spring:message code="general.saveSuccess" />
</body>
</html>

as you seen above, in the Test.jsp i used from spring:message tag, but does not have <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> in the head section of page. 如上所示,在我从spring:message标记使用的Test.jsp ,但在<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>页面的头部。

Now, i want to find all of the pages in my project that have this problem and fix it automatically by IDE(Eclipse or anything else). 现在,我想查找项目中所有存在此问题的页面,并通过IDE(Eclipse或其他任何东西)自动修复它。

for example something like Ctrl + Shift + O shortkey in Eclipse that organize imports in .java files. 例如,Eclipse中的Ctrl + Shift + O快捷键之类的东西可以将.java文件中的导入进行组织。

Eclipse WTP's JSP Editor doesn't offer to do this completely automatically, but it can provide content assist for the taglib directive and its attribute values based on what it finds. Eclipse WTP的JSP编辑器不能完全自动执行此操作,但是可以根据发现的内容为taglib指令及其属性值提供内容帮助。 Proposals for the prefix are based on the URI value. 前缀的建议基于URI值。

URI值提案

Try to use the maven-jspc plugin 尝试使用Maven-jspc插件

This article let me think the plugin checks for taglibs too! 本文让我认为该插件也要检查taglib!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM