There is no Action mapped for namespace [/] and action name [test] associated with context path [...

There is no Action mapped for namespace [/] and action name [test] associated with context path [/s2d]. - [unknown location]

 

stucts2错误 找不到文件路径

可能性:

structs.xml 文件(文件名一个字母都不能出错)应该放在 src文件夹下面。具体配置如下:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">

<!-- START SNIPPET: xworkSample -->
<struts>
	<!-- extends必须写,直接或者间接继承struts-default name自定义 -->
    <package name="struts" extends="struts-default">
    	<!-- name是请求名称,不要写/;class对应action完全限定名=包名+类名   method: 指定处理类所触发的方法 -->
        <action name="test" class="com.wang.struts2.Test">
       	    <!-- result是结果集  name和对应action中的方法的返回值匹配,默认是success -->
            <result name="success">/MyJsp.jsp</result>
        </action>
    </package>
</struts>

配置中的extends="struts-default"  必须写不能错(当然也可以间接继承)

 

web.xml(在WEB-INF文件夹下)  <filter-name>struts2</filter-name> 这个不能写错切记勿写成structs2

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 
	xmlns="http://java.sun.com/xml/ns/javaee" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
	http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
  <filter>
  	<filter-name>struts2</filter-name>
  	<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>
  <filter-mapping>
  	<filter-name>struts2</filter-name>
  	<url-pattern>*.action</url-pattern>
  </filter-mapping>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

处理类(此处不多说)

package com.wang.struts2;

import com.opensymphony.xwork2.Action;

public class Test {
	public String execute(){
		System.out.println("hello Test");
		return Action.SUCCESS;
	}
}

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值