Struts1.3 HTTP Status 500 No action config found for the specified url

来源:互联网 发布:不喜欢令狐冲知乎 编辑:程序博客网 时间:2024/05/07 06:24

HTTP Status 500 - org.apache.struts.chain.commands.InvalidPathException: No action config found for the specified url

利用Struts1.3 MVC框架编写一个小例程,struts配置如下图所示:


项目的文件目录如下图所示:


入口jsp是person.jsp,为一个添加人员信息表单,对应的Form Bean 和Action是PersonForm和PersonAction,在personAction中进行分流,action为add时是person.jsp表单,action为list时列出所有的人员信息。addSuccess为添加成功后的页面,包含向list页面的跳转。代码如下:

<html:html lang="true">  <head>    <html:base />        <title>addSuccess.jsp</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0">    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">-->  </head>    <body>    This a struts page. <br>    ${pageContext.request.contextPath }<br>    添加人员成功。<a href="person.do?action=list">返回人员列表</a>  </body></html:html>
打开浏览器进行测试,在addSuccess页面向list页面进行跳转时,出现如下错误,浏览器uri如下:

查找原因:排除action的配置文件错误;那么就是跳转的路径问题。在地址栏输入:http://localhost:8080/Struts1MVCTest/form/person.do?action=list发现同样出现如下错误,去掉中间的/form路径之后能够显示出列表。

原因是:以person.do?action=list为路径直接访问的URL是http://localhost:8080/Struts1MVCTest/form/person.do?action=list,在/form下提交.do的话struts不会处理,需要在/Struts1MVCTest下提交.do文件。

因此需要将链接的路径修改为:<a href="${pageContext.request.contextPath }/person.do?action=list">返回人员列表</a>。这样就可以解决这个问题了。

0 0