No result defined for action action.LoginAction and result success 问题解决

搭建好SSH2框架,写一个简单的登陆功能,提交表单的时候遇到这个问题:

No result defined for action action.LoginAction and result success 问题解决_第1张图片

配置文件如下:

web.xml:



  	
  
contextConfigLocation
classpath:applicationContext.xml


org.springframework.web.context.ContextLoaderListener

  
    index.jsp
  
  
  	struts2
  	
  		org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
  	
  	
config
struts-default.xml,struts-plugin.xml,struts.xml

  
  
  	struts2
  	*.action
  
    
  	struts2
  	*.jsp
  

spring配置文件:applicationContext.xml:



  	
  
contextConfigLocation
classpath:applicationContext.xml


org.springframework.web.context.ContextLoaderListener

  
    index.jsp
  
  
  	struts2
  	
  		org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
  	
  	
config
struts-default.xml,struts-plugin.xml,struts.xml

  
  
  	struts2
  	*.action
  
    
  	struts2
  	*.jsp
  

struts2.1配置文件struts.xml:




	
	
		
			/success.jsp
			/login.jsp
		
	

    

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 + "/";
%>






My JSP 'login.jsp' starting page











	This is my JSP page.
	

成功跳转页面 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 + "/";
%>






My JSP 'success.jsp' starting page











	This is my JSP page.
	
Welcome!


这个是修改之后的正确代码,原来错误代码的struts.xml中的action的name是login,login.jsp中的action="login.action",将这两个action改成“userLogin”之后就没有问题了,改成Login也是可以的。不知道是什么问题,希望了解的大神们指点一下。


你可能感兴趣的:(login,ssh2,action,配置,java)