错误提示:HTTP Status 404 - There is no Action mapped for namespace / and action name login.
type Status reportmessage There is no Action mapped for namespace / and action name login.description The requested resource (There is no Action mapped for namespace / and action name login.) is not available.
--------------------------------------------------------------------------------Apache Tomcat/6.0.20下面上代码:
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" 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">
<display-name>re</display-name>
<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>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
struts.xml<?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>
<package name="example" namespace="example" extends="struts-default">
<action name="login" class="com.re.example.loginAction">
<result name="success">/success.jsp</result>
<result name="fail">/fail.jsp</result>
</action>
</package>
</struts>loginAction.javapackage example;
public class loginAction {
private String usename;
private String password;
public void setPassword(String password) {
this.password = password;
}
public String getPassword() {
return password;
}
public void setUsename(String usename) {
this.usename = usename;
}
public String getUsename() {
return usename;
}
public String execute() throws Exception{
if(getUsename().equals("admin")&&getPassword().equals("pass")){
return "success";
}
else{
return "fail";
}
}
}index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=ISO-8859-1">
<title>登陆页面</title>
</head>
<body>
<form action="login" method="post">
用户:<input type="text" name="usename"/><br/>
密码:<input type="password" name="password"/><br/>
<input type="reset" value="重置"><input type="submit" value="提交"/>
</form>
</body>
</html>
type Status reportmessage There is no Action mapped for namespace / and action name login.description The requested resource (There is no Action mapped for namespace / and action name login.) is not available.
--------------------------------------------------------------------------------Apache Tomcat/6.0.20下面上代码:
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" 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">
<display-name>re</display-name>
<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>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
struts.xml<?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>
<package name="example" namespace="example" extends="struts-default">
<action name="login" class="com.re.example.loginAction">
<result name="success">/success.jsp</result>
<result name="fail">/fail.jsp</result>
</action>
</package>
</struts>loginAction.javapackage example;
public class loginAction {
private String usename;
private String password;
public void setPassword(String password) {
this.password = password;
}
public String getPassword() {
return password;
}
public void setUsename(String usename) {
this.usename = usename;
}
public String getUsename() {
return usename;
}
public String execute() throws Exception{
if(getUsename().equals("admin")&&getPassword().equals("pass")){
return "success";
}
else{
return "fail";
}
}
}index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=ISO-8859-1">
<title>登陆页面</title>
</head>
<body>
<form action="login" method="post">
用户:<input type="text" name="usename"/><br/>
密码:<input type="password" name="password"/><br/>
<input type="reset" value="重置"><input type="submit" value="提交"/>
</form>
</body>
</html>
解决方案 »
- SOS.......tomcat+jboss
- 请教各位高手了~~~~~~Javamail中的NoSuchProviderException问题???在线等!!!
- maven 问题
- 在接口的方法上写Hibernate DAO注解查询问题?
- 急!!!我持久层使用hibernate,如何在程序中获取oracle数据库中指定自增序列的当前值
- 用Transformer转XML时属性的顺序问题.
- Struts问题:Exception creating bean of class ycproject.LoginForm
- 初级问题
- 我刚刚开始学习EJB有点不明白!
- jb6 weblogin61 sp2 写的Entity ejb2.0 (cmp)遇到以下问题?
- myeclipse 格式化问题
- SSH框架中在Action中调用DAO报空指针
试试
<action name="login" class="com.re.example.loginAction">里面的path呢好久没用过Action了 不知道说的是否正确
改成:<package name="example" namespace="/example" extends="struts-default">2. 在浏览器输入url的时候要用:http://xxxx/example/login.action
改成: <form action="login" namespace='/example' method="post">
"/<App_Name>/login"
就照着Tomcat下面的例子写的都不行。
真是郁闷了。
<form action="login" method="post">
改成:
<s:form action="login" namespace='/example' method="post"> 等等...
<form action="example/login" method="post">
namespace问题,要加入url的
现在是
HTTP Status 404 - There is no Action mapped for action name login.
错误了。
Struts.xml写成了sturts.xml
彻底无语了