struts 2 教程中的第一个示例
我想开始使用 Struts 2 框架,我下载 Struts 2.2.3 ,然后按照此 tutorial 制作第一个示例,但是当我运行具有
<%@ taglib prefix="s" uri="/struts-tags" %>
....
<p><a href="<s:url action='hello'/>">Hello World</a></p>
..
此异常的index.jsp时发生:
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 中,因为当我创建 Web 应用程序时未创建 web.xml 文件?!仅存在 sun-web.xml 文件。
I want to start using Struts 2 framework, I download Struts 2.2.3
, and follow this tutorial to make first example, but when I run the index.jsp which has
<%@ taglib prefix="s" uri="/struts-tags" %>
....
<p><a href="<s:url action='hello'/>">Hello World</a></p>
..
This exception occurs:
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]
I didn't specify any filters in web.xml because web.xml file wass not created when I create the web application ?! There's only sun-web.xml file that exists.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自您自己链接的教程。
你读过吗?创建 web.xml(IDE 通常应该已经完成)并按照教程中的说明在其中声明过滤器。
From the tutorial which you linked yourself.
Did you read it? Create the web.xml (the IDE should usually already have done it) and declare the filter in there as per the instructions in the tutorial.
如果您从 Struts2 开始,请查看 Maven Archtypes。
这里描述了它的工作原理。
使用 Struts2 和 jQuery 创建基于 Java 的 Web 应用程序的 4 个简单步骤
If you start with Struts2 take a look at the Maven Archtypes.
How it works is described here.
4 Easy Steps to create a Java based Web Application with Struts2 and jQuery