No result defined for action action.LoginAction and result success 问题解决
转自:https://blog.csdn.net/dongzhout/article/details/43699699
搭建好SSH2框架,写一个简单的登陆功能,提交表单的时候遇到这个问题:
配置文件如下:
web.xml:
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app version="3.0"
- xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
- <display-name></display-name>
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath:applicationContext.xml</param-value>
- </context-param>
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <welcome-file-list>
- <welcome-file>index.jsp</welcome-file>
- </welcome-file-list>
- <filter>
- <filter-name>struts2</filter-name>
- <filter-class>
- org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
- </filter-class>
- <init-param>
- <param-name>config</param-name>
- <param-value>struts-default.xml,struts-plugin.xml,struts.xml</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>struts2</filter-name>
- <url-pattern>*.action</url-pattern>
- </filter-mapping>
- <filter-mapping>
- <filter-name>struts2</filter-name>
- <url-pattern>*.jsp</url-pattern>
- </filter-mapping></web-app>
spring配置文件:applicationContext.xml:
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app version="3.0"
- xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
- <display-name></display-name>
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath:applicationContext.xml</param-value>
- </context-param>
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <welcome-file-list>
- <welcome-file>index.jsp</welcome-file>
- </welcome-file-list>
- <filter>
- <filter-name>struts2</filter-name>
- <filter-class>
- org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
- </filter-class>
- <init-param>
- <param-name>config</param-name>
- <param-value>struts-default.xml,struts-plugin.xml,struts.xml</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>struts2</filter-name>
- <url-pattern>*.action</url-pattern>
- </filter-mapping>
- <filter-mapping>
- <filter-name>struts2</filter-name>
- <url-pattern>*.jsp</url-pattern>
- </filter-mapping></web-app>
struts2.1配置文件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.objectFactory" value="spring" />
- <package name="default" extends="struts-default" >
- <action name="userLogin" class="LoginAction">
- <result name="success">/success.jsp</result>
- <result name="input">/login.jsp</result>
- </action>
- </package>
- </struts>
LoginAction.java:
- public String execute() {
- // TODO Auto-generated method stub
- return SUCCESS;
- }
登陆页面 login.jsp:
- <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
- <%@taglib prefix="s" uri="/struts-tags"%>
- <%
- String path = request.getContextPath();
- String basePath = request.getScheme() + "://"
- + request.getServerName() + ":" + request.getServerPort()
- + path + "/";
- %>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <base href="<%=basePath%>">
- <title>My JSP 'login.jsp' starting page</title>
- <meta http-equiv="pragma" content="no-cache">
- <meta http-equiv="cache-control" content="no-cache">
- <meta http-equiv="expires" content="0">
- <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
- <meta http-equiv="description" content="This is my page">
- <!--
- <link rel="stylesheet" type="text/css" href="styles.css">
- -->
- </head>
- <body>
- This is my JSP page.
- <br>
- <s:form action="userLogin.action">
- <s:textfield name="username" label="用户名" />
- <s:password name="password" label="密码"></s:password>
- <s:submit type="button" value="登陆" />
- </s:form>
- </body>
- </html>
成功跳转页面 success.jsp:
- <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
- <%@taglib prefix="s" uri="/struts-tags"%>
- <%
- String path = request.getContextPath();
- String basePath = request.getScheme() + "://"
- + request.getServerName() + ":" + request.getServerPort()
- + path + "/";
- %>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <base href="<%=basePath%>">
- <title>My JSP 'success.jsp' starting page</title>
- <meta http-equiv="pragma" content="no-cache">
- <meta http-equiv="cache-control" content="no-cache">
- <meta http-equiv="expires" content="0">
- <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
- <meta http-equiv="description" content="This is my page">
- <!--
- <link rel="stylesheet" type="text/css" href="styles.css">
- -->
- </head>
- <body>
- This is my JSP page.
- <br> Welcome!
- <h5>
- <s:property value="username" />
- </h5>
- <br>
- <h6>
- <s:property value="password" />
- </h6>
- </body>
- </html>
这个是修改之后的正确代码,原来错误代码的struts.xml中的action的name是login,login.jsp中的action="login.action",将这两个action改成“userLogin”之后就没有问题了,改成Login也是可以的。不知道是什么问题,希望了解的大神们指点一下。
No result defined for action action.LoginAction and result success 问题解决的更多相关文章
- HTTP Status 404 - No result defined for action com.csdhsm.struts.action.LoginAction and result error
智商拙计的问题,没有找到为类LoginAction和error找到定义,然后重新去struts.xml去看,我类个去,我居然把result写成了ERROR <result name=" ...
- Struts 2.x No result defined for action 异常
这是我跑struts2的第一个例子,跑的也够郁闷的,这个问题烦了我几个钟... 2011-5-10 10:10:17 com.opensymphony.xwork2.util.logging.co ...
- No result defined for action com.lk.IndexAction and result success
意图访问一个 /es/index.action 竟然出现: [SAE ] ERROR [05-11 13:54:32] [http-80-5] com.opensymphony.xwork2.util ...
- no result defined for action
1.no result defined for action .......and result input 或者 no result defined for action .......and ...
- HTTP Status 404 - No result defined for action com.hebky.oa.classEntity.action.EntitysAction and result input
在开发中总遇到这个问题,No result defined for action:原因:Action中的属性值为空的时候,Struts2的默认拦截器会报错,但是又找不到input的Result,不能够 ...
- Struts2问题,已解决No result defined for action and result input
struts2.1.8 必须在struts.xml中配置namespace属性 如果你在2.0中一切OK,但是在2.1中确出现了No result defined for action的异常,就是在因 ...
- validators配置要点及No result defined for action报错解决方案
在做JavaEE SSH项目时,接触到validators验证. 需要了解validators配置,或者遇到No result defined for action 这个错误时,可查阅本文得到有效解决 ...
- struts异常:No result defined for action
问题描述: No result defined for action com.freedom.funitureCityPSIMS.controller.login.CheckAction and re ...
- SSH配置struts校验发生No result defined for action actions.AdminLoginAction and result input
配置struts校验发生No result defined for action actions.AdminLoginAction and result input,但是登录,success.jsp, ...
- No result defined for action com.nynt.action.ManageAction and result input问题
No result defined for action com.nynt.action.ManageAction and result input 问题原因: 1). 在action类中定义的一个r ...
随机推荐
- Eclipse安装SVN客户端
在Eclipse中安装SVN客户端有个好处,不用兼容其它操作系统都能保持一致的操作.比如再Linux下SVN客户端软件体验相对较差,但是基于命令行的操作却在Linux下无所不能. 一.通过在线安装 地 ...
- Codeforces Beta Round #61 (Div. 2) D. Petya and His Friends 想法
D. Petya and His Friends time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- MySQL随机取数据
// 随机取9个 $rand_sql = "SELECT * FROM `tf_product` WHERE (`id` >= ((SELECT MAX(`id`) FROM `tf_ ...
- Node.js初接触(一)
本来还在纠结着到底要学哪一种后台语言呢,突然发现node.js很火,既然能被这么多人推崇,自然是有他的优势的.去百度百科看了一眼,或许是我理解能力太差,并没有了解到很多关于node.js的东西,大概就 ...
- Adobe 产品更新直接下载链接
mac:http://prodesigntools.com/adobe-cc-2015-updates-links-mac.html win:http://prodesigntools.com/ado ...
- cassandra cqlsh 和 python客户端
Keyspaces A cluster is a container for keyspaces. A keyspace is the outermost container for data in ...
- IntelliJ IDEA配置tomcat【全程详解】
相关博客:IntelliJ IDEA创建Maven+SSM+Tomcat+Git项目[全程详解] 创建好web项目后,需要将项目部署到Tomcat中运行. 接下来,图文解析IntelliJ IDEA如 ...
- java学习笔记--常用类
一.Math类:针对数学运算进行操作的类 1.常用的方法 A:绝对值 public static int abs(int a) B:向上取整 public static double ceil( ...
- stl_hash_set.h
stl_hash_set.h // Filename: stl_hash_set.h // Comment By: 凝霜 // E-mail: mdl2009@vip.qq.com // Blog: ...
- HTTP协议状态代码和错误状态含义的解释
面试互联网公司经常被问的就是HTTP协议的知识,甚至比TCP/IP问的还多,其中HTTP代码的知识也是开发过程中经常会接触的,今天学习所有 HTTP 状态代码及其定义. 代码 指示 2xx ...