struts.xml的代码:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd"><struts>
<constant name="struts.devMode" value="true" />
<package name="testStust2" namespace="/" extends="struts-default">


<action name="aa" class="com.view.Test" method="test">
<result>/result.jsp</result>
</action>
</package>
</struts>
Test.java的代码:
package com.view;import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;public class Test extends ActionSupport{
     public String test(){
      return Action.SUCCESS;
     }
}index.jsp的代码:
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="ISO-8859-1"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  </head>
  
  <body>
    <a href="${pageContext.request.contextPath }/aa">Test</a>
  </body>
</html>
result.jsp的代码:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'result.jsp' starting page</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>
    结果页面 <br>
  </body>
</html>
在WebRoot下创建一个包,名字为aa,并在aa下创建manager.jsp.
(运行环境MyEclipse6.5 + jds1.6)运行http://127.0.0.1:8080/test_struts2/ 后,点击Test出现错误提示如下:
Stacktraces
There is no Action mapped for namespace / and action name aa/. - [unknown location] 测试后发现,如果action的name的值和在WebRoot下创建的包名一样的话,就会出现这个错误,
不知道为什么。但是我又偏偏要用到action的name值和WebRoot下的某个包名一样,因为要拦截这个包。又什么办法解决吗?(前提要求action的name值和WebRoot下的某个包名一样)