[转]No configuration found for the specified action 原因及解决方案
报错内容
警告: No configuration found for the specified action: 'login' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
引发原因
底层原因本人不是太清楚,但我理解的是,由于请求页面的namespace属性与struts.xml的namespace属性值不一致引起的,这种警告基本上不会影响系统的运行,但对于一个追求完善的人来说,不得不说,这并不是一道好的风景。所以,这里,提供一个小小的解决方案供朋友们参与。
由于引发这个警告的只是用于请求的jsp页面和struts.xml两个文件,为了让朋友们更好的理解,这里我将用于测试的代码复制出来,供大家参与。(请求页面:login.jsp struts2配置文件:struts.xml)
(由于下面的jsp页面关联有其他文件,这里就不复制出来了,单独使用可能会有其他的错误。如果读者需要测试的话,可以自己写一个简单的登录页面)
引发警告的文件:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
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><s:property value="getText('loginPage')"/></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>
<s:form action="login" method="post">
<s:textfield name="username" key="user"></s:textfield>
<s:password name="password" key="pass"></s:password>
<s:submit name="submit" key="login"></s:submit>
</s:form>
</body>
</html>
login.jsp
<?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>
<!-- Add packages here -->
<package name="struts0200" namespace="/" extends="struts-default">
<default-action-ref name="index" /> <action name="login" class="com.struts2_0200.LoginAction">
<result name="success">
/welcome.jsp
</result>
<result name="error">
/login.jsp
</result>
</action>
</package>
</struts>
struts.xml
引发警告的的关键之处
login.jsp页面中,<s:form action="login" method="post"> ,此处没有指明namespace属性的值,所以系统会自动的认为namespace的值为警告信息中的那样,namespace: ''
而struts.xml文件中,我们指定的namespace的值为:namespace="/",两处的namespace的值为一致,从而导致了警告的产生。
所以,解决方法很简单,将两个页面的namespace的值改成一样的就行了。这里我修改了login.jsp页面,修改内容如下:
<s:form action="login" method="post" namespace="/">
另外补充一点,这种情况一般发生在Tomcat 6.0及其以后的版本,之前版本的不会发出这种警告。如果不是系统功能的需要,建议不要使用最新版本的服务器。
[转]No configuration found for the specified action 原因及解决方案的更多相关文章
- No configuration found for the specified action解决办法
http://blog.csdn.net/carefree31441/article/details/4857546 使用Struts2,配置一切正常,使用常用tag也正常,但是在使用<s:fo ...
- No configuration found for the specified action解决办法(转)
使用Struts2,配置一切正常,使用常用tag也正常,但是在使用<s:form>标记时,发现控制台总是输出警告信息, 警告信息内容如下: 警告: No configuration fou ...
- [转]No configuration found for the specified action解决办法
使用Struts2,配置一切正常,使用常用tag也正常,但是在使用<s:form>标记时,发现控制台总是输出警告信息, 警告信息内容如下: 警告: ...... <div> h ...
- validators配置要点及No result defined for action报错解决方案
在做JavaEE SSH项目时,接触到validators验证. 需要了解validators配置,或者遇到No result defined for action 这个错误时,可查阅本文得到有效解决 ...
- 基于struts2注解@action的@Result跳转问题——跳转到另一个action
初学ssh 基于注解的方式简单灵活,但是做一个例子的时候,添加用户AddUser 完成后 想页面跳转到 ListUser 这个action, 然后action 成功后 会跳转到list.jsp 显示 ...
- MySQL 5.6 Reference Manual-14.4 InnoDB Configuration
14.4 InnoDB Configuration 14.4.1 InnoDB Initialization and Startup Configuration 14.4.2 Configuring ...
- 基于ASP.NET Core 3.x的端点路由(Endpoint Routing)实现控制器(Controller)和操作(Action)分离的接口服务
本文首发于 码友网 -- <基于ASP.NET Core 3.x的端点路由(Endpoint Routing)实现控制器(Controller)和操作(Action)分离的接口服务> 前言 ...
- Could not execute action
2.Could not execute action 原因:action成员变量有空值,要访问方法中,使用了该成员变量 参考: http://www.blogjava.net/javagrass/ar ...
- 使用VS2012 开发SharePoint 2013 声明式的action(activity) 综合实例
本文讲述使用VS2012 开发SharePoint 2013 声明式的action 综合实例. 需求同: http://blog.csdn.net/abrahamcheng/article/detai ...
随机推荐
- mysql 随笔
(select GROUP_CONCAT(car_brand_name separator ',') carBrandName,supplier_id from ycej_supplier_carbr ...
- 【 SSH 配置参考】
applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xm ...
- jmeter实现服务器端后台接口性能测试
实现目的 在进行服务器端后台接口性能测试时,需要连接到Linux服务器端,然后通过命令调用socket接口,这个过程就需要用到jmeter的SSH Command取样器实现了. 脚本实现 设置CSV ...
- 通过python代码连接MySQL以及插入和显示数据
通过python代码连接MySQL以及插入和显示数据: 数据库huahui创建一个shibie的表,里面有两个varcahr(100)的字段,num和result. import pymysql im ...
- k8s Learning Notes
Kubernetes - 组件介绍 MESOS APACHE 分布式资源管理框架 2019-5 Twitter > Kubernetes Docker Swarm 2019-07 阿里云宣布 D ...
- Leet Code 9.回文数
判断一个整数是否是回文数. 题解 普通解法:将整数转为字符串,然后对字符串做判断. ///简单粗暴,看看就行 class Solution { public boolean isPalindrome( ...
- Servlet线程安全问题(转载)
转载地址:https://www.cnblogs.com/LipeiNet/p/5699944.html 前言:前面说了很多关于Servlet的一些基础知识,这一篇主要说一下关于Servlet的线程安 ...
- IIS反向代理配置教程(最终完整版本)
IIS代理配置教程 插件下载:https://download.csdn.net/download/song_yan_/11996489 一.安装反向代理插件 1.rewrite插件安装 (1) 双击 ...
- Jmeter_接口串联自动化测试_登录后充值获取cookie
1.登陆->充值->运行会报错 2,那如何解决这个问题呢,添加HTTP COokie管理器 另外一种方法,登录->提取正则表达式,充值->添加HTTP cookie管理器
- 16 Z变换
Z变换 由于\(DTFT\)变换是有收敛条件的,并且其收敛条件比较严格,很多信号不能够满足条件,为了有效的分析信号,需要放宽收敛的条件,引入\(Z\)变换. 定义 已知序列的\(DTFT\)为 \[ ...