Struts应用程序中的NullPointer异常 [英] NullPointer Exception in Struts application
问题描述
我想创建一个显示index.jsp文件的struts应用程序,其中包含指向search.jsp文件的链接.Struts 1.2 app的目录结构如下
I want to create a struts app which displays index.jsp file which contains link to the search.jsp file.Directory structure of Struts 1.2 app is as below
Struts 1.2目录列表
web.xml 的内容如下
<display-name>MiniHR</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<jsp-config>
<taglib>
<taglib-uri>http://struts.apache.org/tags-html</taglib-uri>
<taglib-location>/WEB-INF/lib/struts-html.tld</taglib-location>
</taglib>
</jsp-config>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.</url-pattern>
</servlet-mapping>
<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>
</web-app>
struts-config.xml 的内容如下
<global-forwards>
<forward name="search" path="/search.jsp"></forward>
</global-forwards>
index.jsp 的内容如下
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<body>
Add Employee<html:link forward="search">Search Employees</html:link>
</body>
现在,当我在Eclipse上运行该应用程序时,其显示的 HTTP状态500-如下所示
Now when i run this app on eclipse its displaying HTTP Status 500 - as below
我尝试了很少的解决方案,但似乎无法解决问题.希望获得一点帮助.
I tried few solutions but nothing seems to fix the problem.A Little Help would be appreciated.
我已在以下URL中添加了战争文件
I have added the war file in following URL
http://www.fileconvoy.com/dfl.php?id=g6daddfa41e8981249992832312c46545fb6b
谢谢
推荐答案
您的html:link
标记属性forward
错误.
根据 Struts link
标签规范:
According to the Struts link
tag specification:
forward -使用此属性的值作为要查找的全局ActionForward的名称,并使用相对于模块或 在那里找到与上下文相关的URI.如果正向是相对于模块的 那么它必须指向一个动作而不是页面.
forward - Use the value of this attribute as the name of a global ActionForward to be looked up, and use the module-relative or context-relative URI found there. If the forward is module-relative then it must point to an action and NOT to a page.
因此,您的全球前锋应该指向Struts Action,而不是页面.
So, your global forward should point to a Struts Action and not a page.
我希望这可以解决您的问题.
I hope this resolves your problem.
请参阅相关示例 查看全文