struts---No result defined for action org.crazyit.app.action.LoginAction and result error
来源:互联网 发布:linux查看内核版本 编辑:程序博客网 时间:2024/06/06 06:32
必须配上命名空间,第一种方法<s:form name=" register " action="/user/ register " >
<%@ 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=GBK">
<title><s:text name="loginPage"/></title>
</head>
<body>
<s:form action="login" namespace="/user">
<s:textfield name="username" key="user"/>
<s:textfield name="password" key="pass"/>
<s:submit key="login"/>
</s:form>
</body>
</html>
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
"http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<!-- 指定全局国际化资源文件 -->
<constant name="struts.custom.i18n.resources" value="mess"/>
<!-- 指定国际化编码所使用的字符集 -->
<constant name="struts.i18n.encoding" value="UTF-8"/>
<!-- 所有的Action定义都应该放在package下 -->
<package name="lee" extends="struts-default" namespace="/user">
<action name="login" class="org.crazyit.app.action.LoginAction">
<!-- 定义三个逻辑视图和物理资源之间的映射 -->
<result name="error">/error.jsp</result>
<result name="success">/welcome.jsp</result>
</action>
</package>
</struts>
package org.crazyit.app.action;
import com.opensymphony.xwork2.ActionContext;
//import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport
{
//定义封装请求参数的username和password属性
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;
}
//定义处理用户请求的execute方法
public String execute() throws Exception
{
//当username为crazyit.org,password为leegang时即登录成功
if (getUsername().equals("crazyit.org")&& getPassword().equals("leegang") )
{
ActionContext.getContext().getSession().put("user" , getUsername());
return "success";
}
else
{
return "error";
}
}
}
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=GBK">
<title><s:text name="loginPage"/></title>
</head>
<body>
<s:form action="login" namespace="/user">
<s:textfield name="username" key="user"/>
<s:textfield name="password" key="pass"/>
<s:submit key="login"/>
</s:form>
</body>
</html>
welcome.jsp
<%@ page language="java" contentType="text/html; charset=GBK"
pageEncoding="GBK"%>
<%@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>
<title><s:text name="succPage"/></title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
</head>
<body>
<s:text name="succTip">
<s:param>${sessionScope.user}</s:param>
</s:text><br/>
</body>
</html>
error.jsp
<%@ page language="java" contentType="text/html; charset=GBK"
pageEncoding="GBK"%>
<%@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>
<title><s:text name="errorPage"/></title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
</head>
<body>
<s:text name="failTip"/>
</body>
</html>
- struts---No result defined for action org.crazyit.app.action.LoginAction and result error
- No result defined for action action.LoginAction and result success
- No result defined for action action.LoginAction and result success
- No result defined for action action.LoginAction and result success
- The requested resource (No result defined for action org.action.LoginAction and result success) is
- No result defined for action com.weiyi.bbs.action.LoginAction and result success总结
- No result defined for action com.stickon.action.loginAction and result success
- No result defined for action action.LoginAction and result success 解决
- No result defined for action com.standard.action.LoginAction and result success
- 错误日志No result defined for action com.action.LoginAction and result success.
- No result defined for action cn.com.struts2.action.LoginAction and result succeed
- No result defined for action action.LoginAction and result success 问题解决
- No result defined for action xxx.action.LoginAction and result success总结
- struts异常:No result defined for action and result success
- no result defined for action and result
- No result defined for action and result
- No result defined for action and result
- No result defined for action and result
- flash跨域策略文件crossdomain.xml配置详解
- poj 1733 Parity game
- 黑马程序员->集合类 (1
- struts2+spring+hibernate整合时所需的jar包
- 基础知识
- struts---No result defined for action org.crazyit.app.action.LoginAction and result error
- [全程建模]UML被肆意乱用,怎么可能解决问题
- 黑马程序员->集合类 (2 Map
- NorFlash与NandFlash对比
- SpringMVC—介绍
- 报表中如何去掉字符串中的首字符或末字符
- android 瀑布流效果(仿蘑菇街)
- Solr学习总结-改进Solr性能
- SpringMVC—所需要包