No action config found for the specified url

  url路径下找不到action,原因是stuts-config.xml文件配置错误。

  demo的项目文件如下:

  使用jsp文件夹中的login.jsp文件调用action:

<%@ page language="java" contentType="text/html"
pageEncoding="GBK"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>用户登录</title>
</head>
<body>
<!-- 标准登录框 -->
<div id="Login_LoginForm">
<div>账号登录</div>
<form method="post" action="loginng.do">
账号:<input name="username" type="text">
密码:<input name="password" type="password">
<a target="_blank" href="register.jsp">免费注册</a>
<input type="submit" value="登录">
<input type="reset" value="重新输入">
</form>
</div>
</body>
</html>

  web.xml配置文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>StrutsSample</display-name> <servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping> <welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list> </web-app>

  struts-config.xml配置文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans>
<form-bean name="loginForm"
type="org.sunnywen.struts.LoginActionForm">
</form-bean>
</form-beans>
<action-mappings>
<action path="/loginng"
name="loginForm"
type="org.sunnywen.struts.LoginAction">
<forward name="loginSuccess" path="/index.jsp"></forward>
</action>
</action-mappings>
</struts-config>

  LoginActionForm是继承ActionForm的类,LoginAction是继承Action的类,此时运行将会出现错误:org.apache.struts.chain.commands.InvalidPathException: No action config found for the specified url.

  原因是JSP文件是在jsp文件夹中,action="loginng.do"会自动去寻找同一文件夹下(即jsp文件夹)的loginng.do,而在struts-config.xml中配置的action的path是配置在根目录下,所以应当如下进行配置:

<action-mappings>
<action path="/jsp/loginng"
name="loginForm"
type="org.sunnywen.struts.LoginAction">
<forward name="loginSuccess" path="/index.jsp"></forward>
</action>
</action-mappings>

转载请注明转载地址:http://www.cnblogs.com/FlyingPuPu/p/5129631.html

org.apache.struts.chain.commands.InvalidPathException: No action config found for the specified url.的更多相关文章

  1. 【struts 报错】 No action config found for the specified url

    1 type Exception report message org.apache.struts.chain.commands.InvalidPathException: No action con ...

  2. Struts Chain ClassCastException Aop

    我们知道struts的restult type 有很多,但主要就是四种 dispatch,rediret,chain,drdirectaction 要让数据从一个action传到另一个action,就 ...

  3. org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter与org.apache.struts.dispatcher.FilterDispatcher是什么区别?

    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter与org.apache.struts.dispatcher.F ...

  4. Apache Struts 跨站脚本漏洞

    漏洞名称: Apache Struts 跨站脚本漏洞 CNNVD编号: CNNVD-201311-010 发布时间: 2013-11-04 更新时间: 2013-11-04 危害等级:    漏洞类型 ...

  5. Apache Struts 安全措施绕过漏洞(CVE-2013-4310)

    漏洞版本: Apache Group Struts < 2.3.15.2 漏洞描述: BUGTRAQ ID: 62584 CVE(CAN) ID: CVE-2013-4310 Struts2 是 ...

  6. Apache Struts 多个开放重定向漏洞(CVE-2013-2248)

    漏洞版本: Struts < 2.3.15.1 漏洞描述: BUGTRAQ ID: 61196 CVE(CAN) ID: CVE-2013-2248 Struts2 是第二代基于Model-Vi ...

  7. java org.apache.struts.taglib.html.BEAN 没有找到

    index.jsp <body> <a href="login2.do">登陆(struts标签)</a><br> </bod ...

  8. 在Apache Struts中利用OGNL注入

    前言 本文简要介绍了Apache Struts的OGNL注入缺陷,文章中介绍使用简单的应用程序复现OGNL注入.深入研究针对公共漏洞,并理解这类漏洞. 内容 安装Apache Tomcat服务器(入门 ...

  9. 使用Apache Commons Chain(转载)

    原博客出处:http://phil-xzh.iteye.com/blog/321536 使用Commons Chain 作为程序开发人员,我们经常需要对一个实际上程序性的系统应用面向对象的方法.商业分 ...

随机推荐

  1. python-查询员工信息表

    python查询员工信息表 基本要求: 用户可以模糊查询员工信息 显示匹配了多少条,匹配字符需要高亮显示 代码: #!/usr/env python #coding:utf-8 import time ...

  2. c# 用正则表达式获取开始和结束字符串中间的值

    c# 用正则表达式获取开始和结束字符串中间的值 /// <summary> /// 获得字符串中开始和结束字符串中间得值 /// </summary> /// <para ...

  3. (转)PHP文件没有结尾的?>有什么好处?

    1.PHP文件没有结尾的?>有什么好处?-- 防止输出一些不必要的空行或者空格2. 如果你是php和html混编的话结尾?> 还是有必要的,否则会报错. 如果没有?>文件末尾的空白行 ...

  4. Android LayoutInflater和findViewById 源码详解

    LayoutInflater大家很熟悉,简单点说就是布局文件XML解析器,setContentView函数也是调用了LayoutInflater 用法: View view = LayoutInfla ...

  5. (转)Android Touch事件传递机制

    -----来源:http://www.trinea.cn/android/touch-event-delivery-mechanism/ 介绍Android Touch事件的传递机制. 不少朋友私信问 ...

  6. 新建android系统服务

    一.Android系统服务 Android提供了很多系统服务:如ActivityManger,PowerManger,WindowManger,WifiManger等等. 这些服务都是系统启动开始就一 ...

  7. vs2010-error LNK1123: failure during conversion to COFF: file invalid or corrupt

    在项目上右键->Properties-> configuration Properties->Enable Incremental Linking(设置为No). ref: Link ...

  8. 关于User&nbsp;Defined&nbsp;Runtime&nbsp;Attributes的小技巧

    在用XIB里自定制view,button,label...的一些属性时,例如边框宽度,边框颜色等,如下图:

  9. 【USACO 3.1.1】最短网络

    [描述]      农民约翰被选为他们镇的镇长!他其中一个竞选承诺就是在镇上建立起互联网,并连接到所有的场.当然,他需要你的帮助.     约翰已经给他的农场安排了一条高速的网络线路,他想把这条线路共 ...

  10. 【USACO 2.2.4】派对灯

    [描述] 在IOI98的节日宴会上,我们有N(10<=N<=100)盏彩色灯,他们分别从1到N被标上号码. 这些灯都连接到四个按钮: 按钮1:当按下此按钮,将改变所有的灯:本来亮着的灯就熄 ...