当前位置: 代码迷 >> Java Web开发 >> No configuration found for the specified action: 'Login' in namespace: ''. Form解决办法
  详细解决方案

No configuration found for the specified action: 'Login' in namespace: ''. Form解决办法

热度:416   发布时间:2016-04-17 01:10:56.0
No configuration found for the specified action: 'Login' in namespace: ''. Form
请教各位大师,这个问题怎么解决,拜托大家了,帮帮忙,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中


------解决方案--------------------
<package name="amigo" extends="struts-default"> 追加一个namespace="/"

<s:form action="Login" method="post" >
修改为
<form action="/Login.do" method="post"> 使用绝对路径
  相关解决方案