gpt4 book ai didi

java - Struts2、Hibernate与企业应用程序集成时出现JasperException

转载 作者:行者123 更新时间:2023-12-02 18:30:18 25 4
gpt4 key购买 nike

我有一个使用 Struts2、Hibernate 构建的 Web 应用程序,它运行良好。

我在 NetBean 中创建了一个新的企业应用程序。我构建的 Web 应用程序已作为 Java EE 模块添加到企业应用程序中。我选择客户端模块作为 Web 应用程序并尝试运行企业应用程序

但是,网络应用程序无法运行。它告诉我

org.apache.jasper.JasperException: The Struts dispatcher cannot be found.  

This is usually caused by using Struts tags without the associated filter.

Struts tags are only usable when the request has passed through its servlet filter,

which initializes the Struts dispatcher needed for this tag. - [unknown location]

Web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

一旦我从企业应用程序中删除 Web 应用程序并进行清理和构建。该网络应用程序是可以运行的。

补充:

我已经在企业应用程序中添加了库,如下图所示,并更改了过滤器。但错误仍然出现。 enter image description here enter image description here

最佳答案

在将 Web 应用程序添加为企业应用程序作为 JavaEE 模块时,检查是否正确配置了构建路径/类路径。可能存在一些 Unresolved 依赖关系,因此无法找到 Struts 调度程序。

注意:自 Struts 2.1.3 版起,FilterDispatcher 过滤器已被弃用。如果您使用的是最新版本的 Struts2 (> 2.1.3),请使用

org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

相反。既然你得到了 JasperException。您需要了解一些事情为什么会发生此异常:

  • 只要您错过标签或没有正确关闭标签,就会发生这种情况
  • 当你的JSP没有被jasper引擎解析时,它会抛出jasper异常。意味着如果你没有正确编写jsp代码,并且如果你在jsp中放置了任何不可用的资源,那么我们将得到Jasper异常
  • 以下原因可能会导致 jasper Exception。

    构建路径中缺少 1.jsp-api.jar。

    1. Jsp 代码编写不正确。

关于java - Struts2、Hibernate与企业应用程序集成时出现JasperException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13919877/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com