IntelliJ 和 JSP/JSTL 无法在 tomcat7 中为 JSTL 解析 taglib [英] IntelliJ and JSP/JSTL cannot resolve taglib for JSTL in tomcat7

查看:44
本文介绍了IntelliJ 和 JSP/JSTL 无法在 tomcat7 中为 JSTL 解析 taglib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我的 JSTl 代码可以在我的服务器上运行,因为我在 tomcat7 的 Lib 文件夹中有正确的 Jar 文件.这只是一个真正的 IDEA 问题.我的问题归结为我在 IntelliJ 中的文件目录中放置相同 jar 文件的位置.

First of all my JSTl code works on my server because i have the proper Jar file in the Lib folder in tomcat7. This is just really an IDEA problem. My questions comes down to where i put the same jar file in my file directory within IntelliJ.

我在 IntelliJ 和 JSTL 中遇到了错误.

I have ran into a error in IntelliJ and JSTL.

我的问题是当我使用

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

它导致无法使用 uri 解析 taglib.我尝试了不同的 Jar 文件,我知道我必须为我的 servlet 更正版本.

It results in Cannot resolve taglib with uri. I have tried different Jar files and I do know that i have to correct version for my servlet.

我在 Ubuntu Server 15.04 和 IntelliJ 14.1.3 上运行 tomcat7.

Im running tomcat7 on Ubuntu Server 15.04, and IntelliJ 14.1.3.

我尝试通过项目结构导入 jar 文件,并将其包含在不同的地方,但在重新构建项目、关闭并重新打开 IDEA 后仍然出现相同的错误.

I have tried importing the jar file though the Project Structure, and including it in various places but still the same error after re-building the project, and closing down and reopening the IDEA.

此示例代码在部署到 tomcat 时运行,但 IntelliJ 不断出错.

This sample code runs when deployed to tomcat but IntelliJ keeps giving errors.

<table border="1">
    <c:forEach var="a" items="${data}">
        <tr>
            <td>${a}</td>
        </tr>
    </c:forEach>
</table>

<c:forEach begin="0" end="255" var="i">
    <span style='color:rgb(
        <c:out value="${i}"/>,
        <c:out value="${i}"/>,
        <c:out value="${i}"/>);'>
        <c:out value="${i}"/></span> <br />
</c:forEach>

我想知道如何阻止 IntelliJ 在我的语法上给出错误,即使代码有效.

I would like to know how to stop IntelliJ from giving errors on my Syntax even though the code works.

我已阅读 IntelliJ 中的 JSTL 在 JSP 中给出错误

https://www.jetbrains.com/idea/features/jsp_editor.html

仍然没有运气.

推荐答案

首先将这个添加到你的 .jsp 文件的顶部:

First add this to the top of your .jsp file:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

它仍然会出现语法错误,但您可以通过添加 javax.servlet:jstl:1.2 作为模块依赖项来解决该问题.为此,请按照以下步骤操作:

It will still give syntax error but you can fix that by adding javax.servlet:jstl:1.2 as a module dependency. To do that, follow these steps:

  1. 单击您的项目名称,然后按 F4 以显示模块设置对话框.
  2. 然后转到 modules 部分中的 dependencies 选项卡.
  3. 点击绿色的 + 图标 From Maven.
  4. 在搜索栏中搜索 javax.servlet:jstl:1.2 并按 OK,它将下载并添加上述库作为模块.
  5. 现在您不应该有任何语法错误.
  1. Click your project name and press F4 to bring up the module settings dialog.
  2. Then go to the dependencies tab in the modules section.
  3. Click the green + icon library From Maven.
  4. Search for javax.servlet:jstl:1.2 in the search bar and press OK and it will download and add the above mentioned library as a module.
  5. Now you should not have any kind of syntax error.

这篇关于IntelliJ 和 JSP/JSTL 无法在 tomcat7 中为 JSTL 解析 taglib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆