There is no Action mapped for namespace [/] and action name [Login] associated with context path [/e
近期学习web开发时,就遇到这个令人头疼的问题。
百度谷歌了N遍,最终在博客http://blog.csdn.net/liu578182160/article/details/17266879中找到了问题的根源。
开发环境:win7 32位旗舰版,jdk1.7_45,jre7,eclipse4.3.1 JavaEE版,tomcat 7.0.42,struts2.3.16.3
问题出如今web.xml配置
原web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="struts2Demo" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.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>/*</url-pattern>
</filter-mapping> </web-app>
改动后的web.xml:
<?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">
<display-name></display-name> <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>/*</url-pattern>
</filter-mapping> <welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>
关键的差别就在于web-app的version
(似乎不关这版本号问题,刚试了2.4的web-app,能够执行成功。)
可能这不是问题的关键,项目改动的地方还有
原login.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 'login.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>
<form action="login.action" method="post"><!-- login就是struts.xml里的action的name --> 用户名<input type="text" name="username" /> <!-- username相应LoginAction的username通过set方法传入 --> 密码: <input type="password" name="password" /> <!-- password相应LoginAction的password通过set方法传入 -->
<input type="submit" name="Submit" value="Submit"/>
</form>
</body>
</html>
改动后的login.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><s:text name="loginPage"/></title>
</head>
<body> <s:form action="login">
<s:textfield name="username" key="user"/>
<s:textfield name="password" key="pass"/>
<s:submit key="login" value="Submit"/>
</s:form> </body>
</html>
There is no Action mapped for namespace [/] and action name [Login] associated with context path [/e的更多相关文章
- struts2中错误There is no Action mapped for namespace [/] and action name [] associated with context path
1 There is no Action mapped for namespace [/] and action name [] associated with context path [/Stru ...
- Struts2中关于"There is no Action mapped for namespace / and action name"的总结
今天在调试一个基础的Struts2框架小程序.总是提示"There is no Action mapped for namespace / and action name"的错误. ...
- 报错:HTTP Status 404 - There is no Action mapped for namespace [/] and action name [product-save] associated with context path [/20161101-struts2-2].
运行:index.jsp---->input.jsp----->details.jsp,但是在input.jsp到details.jsp的时候报错误. 异常如下: 严重: Could no ...
- Struts2-tomcat报错:There is no Action mapped for namespace / and action
HTTP Status 404 - There is no Action mapped for namespace / and action name first. type Status repor ...
- There is no Action mapped for namespace [/pages/action/student] and action name [findStudent]
1.错误描写叙述 2014-7-13 2:38:54 org.apache.jasper.compiler.TldLocationsCache tldScanJar 信息: At least one ...
- There is no Action mapped for namespace / and action name UserAction
果断收藏了,说的非常具体.刚開始学习的人常常遇到的问题. There is no Action mapped for namespace / and action name UserAction 在网 ...
- eclipse中配置struts2出现There is no Action mapped for namespace [/] and action name [Login] associated wi
下午在eclipse中配置struts2时报: There is no Action mapped for namespace [/] and action name [Login] associat ...
- eclipse使用SSH框架出现There is no Action mapped for namespace [/] and action name [] associated with context path错误
eclipse使用SSH框架出现There is no Action mapped for namespace [/] and action name [] associated with conte ...
- struts 2.5 There is no Action mapped for namespace [/] and action name [user_find] associated with context path [/struts2_crm].
遇到了这个错误. There is no Action mapped for namespace [/] and action name [user_find] associated with con ...
- Could not find action or result: There is no Action mapped for namespace [/] and action name [GetG
Could not find action or result: /car/GetGpsDataAction There is no Action mapped for namespace [/] ...
随机推荐
- java 获取路径的各种方法
(1).request.getRealPath("/");//不推荐使用获取工程的根路径 (2).request.getRealPath(request.getRequestURI ...
- 三十三 StringIO和BytesIO
StringIO 很多时候,数据读写不一定是文件,也可以在内存中读写. StringIO顾名思义就是在内存中读写str. 要把str写入StringIO,我们需要先创建一个StringIO,然后,像文 ...
- TopTicTacToe 开发文档
团队成员: 1.张旭 2.余浩 3.孙闯 4.吴阳 5.王晓华 6.张国庆 开发文档地址:http://www.kancloud.cn/netcon/t4 代码项目地址:https://coding. ...
- Java synchronized的原理解析
开始 类有一个特性叫封装,如果一个类,所有的field都是private的,而且没有任何的method,那么这个类就像是四面围墙+天罗地网,没有门.看起来就是一个封闭的箱子,外面的进不来,里面的出不去 ...
- hdu 1874 畅通工程续(迪杰斯特拉优先队列,floyd,spfa)
畅通工程续 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm ...
- Linux-I/O五种模型
一. 概念说明 在进行解释之前,首先要说明几个概念: 用户空间和内核空间 进程切换 进程的阻塞 文件描述符 缓存 I/O 同步(Sync)/异步(Async) 阻塞(Block)/非阻塞(Unbloc ...
- 【BZOJ 3289】 3289: Mato的文件管理 (莫队)
3289: Mato的文件管理 Time Limit: 40 Sec Memory Limit: 128 MBSubmit: 2819 Solved: 1185 Description Mato同 ...
- java switch
韩梦飞沙 韩亚飞 313134555@qq.com yue31313 han_meng_fei_sha switch 是 开关:转换 的意思. 支持的数据类型 有 : 字节,字符,短整型,整型 ...
- 网络流24题之最长k可重线段集问题
对于每个线段拆成两个点,如同之前一样建图,由于可能出现垂直于x轴的 所以建图由i指向i~ 继续最小费用最大流 By:大奕哥 #include<bits/stdc++.h> using na ...
- 【最小表示法】BZOJ2882-工艺
[题目大意] 求一个循环数列的最小表示法. [思路] 最小表示法模板题.之前用SAM做的,MLE了hhhhh戳☆ #include<iostream> #include<cstdio ...