“jasper异常。找不到Struts分派程序。”

huangapple 未分类评论46阅读模式
英文:

jasper exception. The Struts dispatcher cannot be found

问题

我有两个JSP文件:

  • index.jsp(没有Struts 2标签)
  • login.jsp(带有Struts 2标签)

我用<a href="login.jsp">LOGIN IN</a>标签将login.jsp链接到index.jsp

当点击时,页面不加载,而是抛出错误:

(ERROR:org.apache.jasper.JasperException: 找不到Struts分派程序。).

如果从login.jsp中移除所有的Struts标签,它就能正常工作。

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
     version="3.1">
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>

    </filter>

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
</web-app>

如何在带有Struts 2标签的情况下运行我的应用程序?

英文:

I have two JSP files:

  • index.jsp (with no Struts 2 tags)
  • login.jsp (with Struts 2 tags)

I have linked to login.jsp to index.jsp with &lt;a href=&quot;login.jsp&quot;&gt;LOGIN IN&lt;/a&gt; tag.

When clicked the page doesn't load, instead throws the error:

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

If all the struts tag are removed from login.jsp it works fine.

web.xml

    &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
    &lt;web-app xmlns=&quot;http://xmlns.jcp.org/xml/ns/javaee&quot;
    	 xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
    	 xsi:schemaLocation=&quot;http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd&quot;
    	 version=&quot;3.1&quot;&gt;
        &lt;filter&gt;
            &lt;filter-name&gt;struts2&lt;/filter-name&gt;
            &lt;filter-class&gt;org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter&lt;/filter-class&gt;
    
        &lt;/filter&gt;
        
        &lt;filter-mapping&gt;
            &lt;filter-name&gt;struts2&lt;/filter-name&gt;
            &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
        &lt;/filter-mapping&gt;
        &lt;welcome-file-list&gt;
            &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
        &lt;/welcome-file-list&gt;
        &lt;session-config&gt;
            &lt;session-timeout&gt;
                30
            &lt;/session-timeout&gt;
        &lt;/session-config&gt;
    &lt;/web-app&gt;

How to run my application with Struts 2 tags on it?

答案1

得分: 0

如果页面上有S2标签,则必须通过操作来访问。

S2标签期望来自框架的数据。

英文:

If there are S2 tags on a page it must be reached via an action.

S2 tags expect data from the framework.

huangapple
  • 本文由 发表于 2020年5月4日 01:18:02
  • 转载请务必保留本文链接:https://java.coder-hub.com/61578658.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定