You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

IntelliJ中出现Unable to find taglib [s] for URI: [/struts-tags]错误的解决求助

解决IntelliJ中Struts项目"Unable to find taglib [s] for URI: [/struts-tags]"错误

问题背景

开发Struts项目时,Eclipse环境配置正常,但切换到IntelliJ后出现报错:

"Unable to find taglib [s] for URI: [/struts-tags]"

已尝试删除.m2文件夹并重新执行mvn install,也将struts2-core-2.3.37.jar中的struts-tags.tld文件放置到WEB-INF目录根下,但问题仍未解决。使用的Tomcat版本为tomcat-embed-core-9.0.37.jar,pom.xml中包含velocity-tools 2.0依赖并排除了旧版Struts相关组件。

解决方案

  • 确认Struts2核心依赖存在
    确保pom.xml中已正确引入struts2-core依赖,因为struts-tags.tld默认包含在该jar包内。如果缺失,添加以下配置:

    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-core</artifactId>
        <version>2.3.37</version>
    </dependency>
    
  • 强制刷新Maven依赖
    手动触发IntelliJ的Maven同步:右键项目 → 选择「Maven」→「Reload Project」,确保所有依赖已下载并加入项目classpath。

  • 检查Web Artifact部署配置

    1. 打开「File」→「Project Structure」→「Artifacts」
    2. 找到当前项目对应的Web Artifact,展开「WEB-INF/lib」目录
    3. 确认其中包含struts2-core-2.3.37.jar,如果没有,点击右上角「+」→「Library Files」,选中struts2-core依赖添加进去
    4. 应用配置并重新部署项目
  • 验证JSP标签库声明
    检查报错的JSP页面中,taglib声明是否正确,确保格式如下:

    <%@ taglib prefix="s" uri="/struts-tags" %>
    

    注意URI和prefix不要拼写错误。

  • 清理IntelliJ缓存
    打开「File」→「Invalidate Caches...」,选择「Invalidate and Restart」,重启IDE后重新构建项目,避免缓存导致的依赖识别问题。

  • 检查Tomcat部署目录
    前往IntelliJ Tomcat的实际部署目录(通常在out/artifacts/[项目名]/WEB-INF/lib),确认struts2-core-2.3.37.jar存在。如果缺失,重新配置Artifacts确保依赖被正确拷贝。

内容的提问来源于stack exchange,提问作者Zrahs

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 20:22:08