简体   繁体   English

Struts 绝对 uri:http://struts.apache.org/tags-bean 无法在 web.xml 或与此应用程序一起部署的 jar 文件中解析

[英]Struts The absolute uri: http://struts.apache.org/tags-bean cannot be resolved in either web.xml or the jar files deployed with this application

Using Servlet 3.0, Maven 4.0, JDK 8 with compliance 1.8.使用 Servlet 3.0、Maven 4.0、符合 1.8 的 JDK 8。 I don't know if the problem is due to eclipse not being able to build the project against the libraries correctly, or if it's tomcat.我不知道问题是由于 eclipse 无法针对库正确构建项目,还是由于 tomcat。 It may be a permission issue, despite the fact that i'm running both tomcat and eclipse as root, but who knows.这可能是一个权限问题,尽管我以 root 身份同时运行 tomcat 和 eclipse,但谁知道呢。 At this point i'm starting to run out of ideas.在这一点上,我开始没有想法了。

Libs Imported导入的库

The index.jsp index.jsp

    <%@ page language="java" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type">
<title>Page d'Acceuil</title>
</head>
<body>
    <html:form action="/ajouter">
        <table border="1">
            <caption>Gestion des etudiants STRUTS 1</caption>
            <tr>
                <td>Nom:<input type="text" name="nom"/></td>
                <td>Prenom:<input type="text" name="prenom"/></td>
                <td>Cin:<input type="text" name="cin" /></td>
            </tr>
        <tr>
            <td><input type="submit" value="Recherche Etudiant" onclick="recherche()"/></td>
            <td><input type="submit" value="Ajouter Etudiant" onclick="ajout()"/></td>
            <td><input type="submit" value="Supprimer Etudiant" onclick="sup()"/></td>
        </tr>
    </table>
    </html:form>
</body>
        <script type="text/javascript">
            function ajout(){
                this.document.forms[0].action="ajouter.do";
                this.document.forms[0].submit();
            }
            function recherche(){
                this.document.forms[0].action="rechercher.do";
                this.document.forms[0].submit();
            }
            function sup(){
                this.document.forms[0].action="supprimer.do";
                this.document.forms[0].submit();
            }
        </script>
</html>

My index.jsp requests leads to either this error :我的 index.jsp 请求会导致此错误:

    Type Exception Report

Message The absolute uri: http://struts.apache.org/tags-bean cannot be resolved in either web.xml or the jar files deployed with this application

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

org.apache.jasper.JasperException: The absolute uri: http://struts.apache.org/tags-bean cannot be resolved in either web.xml or the jar files deployed with this application
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:55)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:277)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:75)
    org.apache.jasper.compiler.TagLibraryInfoImpl.generateTldResourcePath(TagLibraryInfoImpl.java:250)
    org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:125)
    org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:421)
    org.apache.jasper.compiler.Parser.parseDirective(Parser.java:479)
    org.apache.jasper.compiler.Parser.parseElements(Parser.java:1435)
    org.apache.jasper.compiler.Parser.parse(Parser.java:139)
    org.apache.jasper.compiler.ParserController.doParse(ParserController.java:227)
    org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:201)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:358)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:338)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:325)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:580)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

Or this one :或者这个:

    Type Exception Report

Message java.lang.ClassNotFoundException: org.apache.jsp.index_jsp

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
    org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:176)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

Root Cause

java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
    java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:131)
    org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:62)
    org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:171)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

Note The full stack trace of the root cause is available in the server logs.

My web.xml is as following, as you can see even if i supposedly shouldn't be adding these taglibs in there since i'm using servlet 3.0, i'm still declaring them just in case.我的 web.xml 如下,你可以看到即使我不应该在那里添加这些标签库,因为我使用的是 servlet 3.0,我仍然声明它们以防万一。

    <?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>Etudiant</display-name>

  <!-- Servlet controleur de Struts -->
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <!-- Mapping des url avec la servlet -->
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>

  <!-- page d'accueil de l'application -->
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

  <jsp-config>
  <taglib>
     <taglib-uri>
      http://struts.apache.org/tags-bean
     </taglib-uri>
     <taglib-location>
      /WEB-INF/struts-bean.tld
     </taglib-location>
</taglib>
<taglib>
     <taglib-uri>
      http://struts.apache.org/tags-html
     </taglib-uri>
     <taglib-location>
      /WEB-INF/struts-html.tld
     </taglib-location>
</taglib>
<taglib>
     <taglib-uri>
      http://struts.apache.org/tags-logic
     </taglib-uri>
     <taglib-location>
      /WEB-INF/struts-logic.tld
     </taglib-location>
</taglib>
  </jsp-config>
</web-app>

My deployment assembly and java build path are also updated correctly to include those libs, but none of this seems to solution the problem.我的部署程序集和 java 构建路径也正确更新以包含这些库,但这似乎都不能解决问题。

If you have any idea, i would gladly look into it.如果您有任何想法,我很乐意调查。

SOLUTION :解决方案 :

I've managed to resolve this problem by following these steps :我已经按照以下步骤设法解决了这个问题:

1) Remove all the tlds. 1) 删除所有 tlds。 and struts jars from lib.和来自 lib 的 struts jars。

2) Convert the project to maven nature 2)将项目转换为maven性质

3) Have the following dependencies added to the pom.xml 3)在pom.xml中添加以下依赖

 <dependencies>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.struts/struts-core -->
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts-core</artifactId>
        <version>1.3.10</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.struts/struts-taglib -->
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts-taglib</artifactId>
        <version>1.3.10</version>
    </dependency>
</dependencies>

4) Use the corresponding struts configuration dtd in struts-config header, for me it was the following since i was using Struts 1.3 : 4) 在 struts-config 标头中使用相应的 struts 配置 dtd,对我而言,由于我使用的是 Struts 1.3,因此如下所示:

    <!DOCTYPE struts-config PUBLIC
   "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
   "http://struts.apache.org/dtds/struts-config_1_3.dtd">

5) Make sure the action(s) bracket(s) syntax is correct : 5) 确保操作括号语法正确:

<action path="/ajouter" input="/index.jsp" name="myFormBean"
         type="org.your.pckg.src.MyServletAction">
            <forward name="success" path="/redirection_page.jsp" />
        </action>

And that's pretty much it, you may also have to change your java compliance as i had to downgrade from 1.8 to 1.7 to make it work.差不多就是这样,您可能还需要更改 Java 合规性,因为我必须从 1.8 降级到 1.7 才能使其工作。

Ultimately this doesn't answer the question why the previous error pages were showing up despite the fact that all libraries were seemingly well imported and declared, i suspect the root of the problem to be lying in a compatibility issue between either tomcat or eclipse and the struts jars used, preventing the compiler from accessing the tld files and reading them.最终,这并没有回答为什么尽管所有库似乎都被很好地导入和声明,但为什么会出现以前的错误页面的问题,我怀疑问题的根源在于 tomcat 或 eclipse 与使用 struts jars,防止编译器访问 tld 文件并读取它们。 At any rate what seems to appear clear through this is the inability of the server to deploy the tlds, the reason of this has yet to be defined.无论如何,通过这种方式似乎很清楚的是服务器无法部署 tld,其原因尚未确定。

I get the same error as I had a conflict between the jar files being added by me separately and additionally being called in the pom.xml.我得到了同样的错误,因为我在单独添加的 jar 文件和在 pom.xml 中另外调用的 jar 文件之间存在冲突。 Make sure you depend only on one jar in a single way.确保您只以一种方式依赖一个罐子。 I only added jars through maven (pom.xml) Maven Dependency jars我只通过 maven (pom.xml) Maven Dependency jars 添加了 jars

暂无
暂无

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

相关问题 绝对的uri:http://www.springsource.org/tags/form无法在web.xml或使用此应用程序部署的jar文件中解析 - The absolute uri: http://www.springsource.org/tags/form cannot be resolved in either web.xml or the jar files deployed with this application 绝对uri:http://www.springframework.org/tags不能在web.xml或与此应用程序一起部署的jar文件中解析 - The absolute uri: http://www.springframework.org/tags cannot be resolved in either web.xml or the jar files deployed with this application 为什么会出现错误“绝对 uri:[http://tiles.apache.org/tags-tiles] 无法在 web.xml 或部署的 jar 文件中解析” - Why getting error “The absolute uri: [http://tiles.apache.org/tags-tiles] cannot be resolved in either web.xml or the jar files deployed” 如何解决&#39;绝对uri:http://java.sun.com/portlet无法在web.xml或使用此应用程序部署的jar文件中解析&#39; - How to fix 'The absolute uri: http://java.sun.com/portlet cannot be resolved in either web.xml or the jar files deployed with this application' 无法在web.xml或使用此应用程序部署的jar文件中解析绝对uri - The absolute uri cannot be resolved in either web.xml or the jar files deployed with this application 绝对的uri:http://java.sun.com/jsp/jstl/core无法在web.xml或使用此应用程序部署的jar文件中解析 - The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this app 无法在web.xml或jar文件中解析Struts标签-tiles - Struts tags-tiles cannot be resolved in either web.xml or the jar files 绝对uri:http://java.sun.com/jsp/jstl/core不能在web.xml或tomcat中与此应用程序错误一起部署的jar文件中解决 - Absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application error in tomcat JBoss 6x绝对uri:http://java.sun.com/jsp/jstl/core不能在web.xml或与此应用程序一起部署的jar文件中解析 - JBoss 6x The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application JSTL错误:绝对uri:http://java.sun.com/jsp/jstl/core不能在web.xml或与此应用程序一起部署的jar文件中解析 - JSTL error: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM