初学Struts2,感觉一碰到struts.xml文件就各种容易出些莫名其妙的问题错误提示找不着北
下面这个问题一直解决不了:
struts.xml文件:<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
"http://struts.apache.org/dtds/struts-2.1.7.dtd">
<struts>
<constant name="struts.ognl.allowStaticMethodAccess" value="true" />
<package name="default" namespace="/" extends="struts-default">
<action name="*Action" class="org.crazyit.app.action.LoginAction" method="{1}">
<result name="my">/exception.jsp</result>
<result name="input">/login.jsp</result>
<result name="error">/error.jsp</result>
<result name="success">/welcome.jsp</result>
</action>
<action name="tag" class="org.crazyit.app.action.TagAction" >
<result name="success">/welcome.jsp</result>
</action>
</package>
</struts>
两个action文件LoginAction和TagAction是放在同一个包下的,没有什么功能,就是返回一下“success”、“error"这些。写了两个jsp文件,第一个是在form里调用了LoginAction:<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><s:text name="loginPage" /></title>
</head>
<body>
<s:form action="loginAction" method="post">
    <s:textfield name="username" key="user"/>
    <s:password name="password" key="pass" />
    <s:submit key="login" theme="simple"/>
    <s:submit key="registe" theme="simple" method="registe" />
</s:form>
</body>
</html>
这个没什么问题,正常调用了LoginAction。可是另外一个jsp文件仅仅是使用action标签调用TagAction,就一直提示:
严重: Could not execute action: /tag
There is no Action mapped for action name tag. - [unknown location]
没法正确执行。这个jsp文件很简单:<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Struts2 Tags</title>
</head>
<body>
<s:action name="tag" />
</body>
</html>
检查半天没发现哪不对,我在第一个jsp文件里,直接把<s:form action="loginAction" method="post">改成<s:form action="tag" method="post">都是能正常调用到TagAction,产生相应的结果的,为什么到了action标签这就一直提示没有映射到tag的action呢?
而且我在第二个jsp里吧action标签里的tag换成loginAction也提示一样的错误:没有映射到loginAction的action。
另外,相应的文件的位置都是正确的。太奇怪了,实在是理解不了大神们帮我看看到底是哪用错了?脆弱的struts.xml,折磨疯了strutsaction