使用MyEclipse8.5 + tomcat6.0进行开发。
这是一个登录验证程序。
已经把structs资源包中的blank项目中的jar放到myeclipse的lib目录中
代码部分见下
错误信息
严重:
Could not find action or result
There is no Action mapped for namespace / and action name login. - [unknown location] ......
===================================================================
/**********************以下为代码和配置文件**********************/
===================================================================
LoginAction.java程序如下:
package com.struts.action;
public class LoginAction {
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String execute() {
if (username.trim().equals("www") && (password.equals("www"))) {
return "success";
} else {
return "failed";
}
}
}
===============================================================
index.jsp文件代码如下:
<body>
<center>
<h1 align="center">
用户登录
</h1>
<form action="login.action" method="post">
姓名:
<input type="text" name="username" />
<br>
密码:
<input type="text" name="password" />
<br>
<br>
<br>
<input type="submit" name="submit" value="登录" />
</form>
</center>
</body>
================================================================
success.jsp和failed.jsp代码非常相似,如下:
success.jsp
<body>
<h1>欢迎登录!</h1>
</body>
failed.jsp
<body>
<h1>
登录失败!
</h1>
<a href="index.jsp">返回</a>
</body>
================================================================
其中struts.xml配置如下:
<struts>
<package namespace="" name="login"
extends="struts-default">
<action name="login" class="com.struts.action.LoginAction">
<result name="success">/success.jsp</result>
<result name="failed">/failed.jsp</result>
</action>
</package>
</struts>
=================================================================
web.xml配置如下:
<filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
=================================================================
/*******************一下为解决方法****************************/
=================================================================
刚开始时,输入用户名和密码点击登录按钮时,就会显示http;status 404错误,
There is no Action mapped for namespace / and action name login,经过仔细观察,解决方法如下:
1.将struts.xml一定要放在
src目录下,这样在程序编译时,就会将其放到classes目录下。
2.一定要将struts.xml中的extends="struts-default"写正确,刚开始的时候,把default写成了dafult,最后经过改正,程序可以正常运行了!
3.插一句,namespace写不写都影响不大的。
一定要注意以上红色字体和蓝色字体部分,这个是程序能否正常运行的关键!!!
分享到:
相关推荐
前几天在网上下载一个struts2的helloword的例子,那个作者也真够缺德的,搞个错误的程序,害得我查了一天的程序错误。 最后发现竟然是struts.xml被写成啦sturts.xml。 碰见这样的问题先鄙视下提供例子的作者, 再...
HTTP Status 404 - There is no Action mapped for namespace and action name BackMemberGroupAudit..doc
该文档对weblogic使用过程中,包括下载,安装,部署...6. weblogic部署war包action不能访问问题解决方法 [There is no Action mapped for namespace / and action name]. 5 7. java.lang.StackOverflowError. 5 等等
http://localhost:8080/ struts2会拦截,出现异常信息 There is no Action mapped for namespace / and action name.默认配置的welcomefile没有起作用。 按附件配置即可解决此问题
在网上找了好个struts2的例子结果都不好使报There is no Action mapped for namespace / and action name这个错,没办法自己搞了个好用的,myeclipse 6.0 +tomcat5.5 + jdk 1.5 引入项目后直接发布就可以了!
There is no flow logic, no business logic, and no model information -- just tags. Tags are one of the things that make Struts unique compared to other frameworks like Velocity. Note: "Think thin" ...
MDB: A Memory-Mapped Database and Backend for OpenLDAP
To reserve or commit memory and unintentionally not release it when it is no longer being used. A process can leak resources such as process memory, pool memory, user and GDI objects, handles, threads...
Stops the action invocation immediately (by throwing a PauseException) and causes the action invocation to return the specified result, such as Action.SUCCESS, Action.INPUT, etc. void ...
is larger than the largest known FADT version, and 2) if there is a mismatch between a 32-bit block address and the 64-bit X counterpart (when both are non-zero.) Example Code and Data Size: These ...
Memory-Mapped Files for Qualcomm Brew By Ray Rischpater
This document derives useful formulae for working with the Lie groups that represent transformations in 2D and 3D space. A Lie group is a topological group that is also a smooth manifold, with some ...
开发中,我们常常会遇到很多异常报错,现在就我工作中经常遇到...解决:修改请求方式 或 修改请求地址 补充:遵循 RESTful API的开发风格,就算 api地址一样,只要 RequestMapping 请求类型相同,是不会报错的。 详情看
When mapping from an ER model to a relational model, a strong entity is mapped into a (a) table (b) row (c) column (d) key Correct answer is (a) 10. Which of the following is true about ...
Fixed comparing against disconnected mapped network drives to prompt for username/password and reconnect.
/* It is no longer available */ current_location_mcb->is_available = 0; /* We own it */ memory_location = current_location; /* Leave the loop */ break; } } /* If we made...
string1 sets the window title and string2 the process name (on Linux) -uuid x-x-x-x-2x specify machine UUID Display options: -display sdl[,frame=on|off][,alt_grab=on|off][,ctrl_grab=on|off] [,...
MemoryMappedFile 使用 C# 内存中分配一大块地址. 前边分配一个用与共同配置用 后边N个结构体 for循环建 一般用到此问题,两本程序 一个读一个写 循环读写 ----2015/09/24 Lyndon 上海----
3. There is a point light and a single directional light in the scene. 4. There is one rotating triangle floating in the air, casting a shadow on the table, walls and other objects. 5. The program ...
For a node's Mapped Rx signal, the assigned value table is displayed in the dialog box in addition to the overview. For user-defined attributes with the type "hex" it is now possible to define the min...