struts的url加action和不加action为什么访问不一样?

http://localhost:8080/HelloWorldStruts/name.action

<form id="HelloWorld" name="HelloWorld" onsubmit="return true;" action="/HelloWorldStruts/HelloWorld.action" method="post"></form>

http://localhost:8080/HelloWorldStruts/index.jsp

<form id="HelloWorld" onsubmit="return true;" action="HelloWorld" method="post"></form>

这两个是同一个网页, 第一个是在struts.xml中的action中配置的, 第二个是在web.xml中的welcome-file-list中配置的,但是加了action的网页可以继续成功提交请求,而以jsp结尾的则是报错404,无法找到/HelloWorldStruts/HelloWorld

这是这个网页的内容

<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Name Collector</title>
</head>
<body>
    <s:form action="HelloWorld">
    </s:form>
    <hr>    
</body>
</html>

为什么会有这么大不同呢?

阅读 3.1k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进