No configuration found for the specified action: 'Login' in namespace: ''. Form

WCH_123 2011-08-09 06:44:06
请教各位大师,这个问题怎么解决,拜托大家了,帮帮忙,JSP页面提交按钮提交后就出这问题了。控制台信息容下:
09-八月-11 下午 06:42 org.apache.struts2.components.Form evaluateExtraParamsServletRequest
WARNING: No configuration found for the specified action: 'Login' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
09-八月-11 下午 06:42 org.apache.struts2.components.Form evaluateExtraParamsServletRequest
WARNING: No configuration found for the specified action: 'Login' in namespace: ''. Form action defaulting to 'action' attribute's literal value.



struts.xml:

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<include file="struts-default.xml"/>
<package name="amigo" extends="struts-default">
<!-- 配置登录的Action -->
<action name="Login" class="amigo.struts.login.action.LoginAction" >
<result>/success.jsp</result>
<result name="input">/login.jsp</result>
</action>
</package>

</struts>


login.jsp:

<%@ page contentType="text/html;charset=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>登录系统</title>
</head>
<body>
<div align="center">
${requestScope.message}
<s:form action="Login" method="post" >

<s:textfield name="loginName" size="20" label="用户名"/>
<s:password name="password" size="20" label="密码"/>
<s:submit value="提交"/>
</s:form>
</div>
</body>
</html>



LoginAction.class:

package amigo.struts.login.action;

import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport {


public String loginName;
public String password;
public String message;

public String getLoginName() {
return loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}


public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String execute() throws Exception{
if("amigo".equals(loginName)&&"amigo".equals(password))
message=loginName+"登录成功!";
else{
message=loginName+"登录失败!";
return INPUT;
}
return SUCCESS;
}
}


是在struts2中
...全文
1400 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
luohuijun619 2011-08-19
  • 打赏
  • 举报
回复
<s:form action="Login.do" method="post" >
songzhd 2011-08-19
  • 打赏
  • 举报
回复
form表单的action要加上扩展名。。。。。。。。
至于命名空间,比较鸡肋,用不用的无所谓。。。。。。
LLCforever 2011-08-19
  • 打赏
  • 举报
回复
试试这个
<package name="amigo" namespace="/" extends="struts-default">

<s:form action="Login" namespace="/" method="post">
WCH_123 2011-08-10
  • 打赏
  • 举报
回复
照你的改法,还是不行,出现了如下结果
HTTP Status 404 - /Login.do

--------------------------------------------------------------------------------

type Status report

message /Login.do

description The requested resource (/Login.do) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.18


控制台的如下:
WARNING: Settings: Could not parse struts.locale setting, substituting default VM locale
Fly_m 2011-08-09
  • 打赏
  • 举报
回复
<package name="amigo" extends="struts-default"> 追加一个namespace="/"

<s:form action="Login" method="post" >
修改为
<form action="/Login.do" method="post"> 使用绝对路径
WCH_123 2011-08-09
  • 打赏
  • 举报
回复
我真的很急啊,求求各位大师们赶紧帮我看下哈!

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧