Code Bye

java ee Could not find action or result

 
警告: Could not find action or result
No result defined for action com.java.action.LoginAction and result success
	at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:375)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277)
	at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
	at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
	at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
	at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)
	at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879)
	at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:617)
	at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1774)
	at java.lang.Thread.run(Thread.java:619)

错误异常

package com.java.action;


import com.java.role.Users;
import com.java.users.DAO.UsersDAO;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String memberID;	            //用户名
	private String password;	        //密码
	private String tip;		            //服务器提示的tip属性
		public String getMemberID() {
		return memberID;
	}
	public void setMemberID(String memberID) {
		this.memberID = memberID;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getTip() {
		return tip;
	}
	public void setTip(String tip) {
		this.tip = tip;
	}
		public String login()throws Exception{
		Users users=new Users();
		users.setMemberID(memberID);
		users.setPassword(password);
		UsersDAO dao=new UsersDAO();
		boolean flag=dao.login(users);
		//如果为true,登录通过
		if(flag){
			//将用户名存入session
			ActionContext.getContext().getSession().put("memberID", memberID);
			return SUCCESS;
		}else	{
			this.setTip(this.getText("login.failed"));//登录失败,返回首页
			return INPUT;
		}
	}

}
package com.java.Database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DatabaseDAO {
	private static Connection con;
	private static final String DRIVER = "com.mysql.jdbc.Driver";
	private static final String URL ="jdbc:mysql://localhost:3306/db";
	private static final String NAME="root";
	private static final String PASSWORD="123456";
	// 类似单例模式 加载一次即可获取驱动
	static{
		try {
			Class.forName(DRIVER);
		} catch (ClassNotFoundException e) {e.printStackTrace();}
	}
	//获取数据库连接
	public static Connection getConnection(){
		try {
			con=DriverManager.getConnection(URL, NAME, PASSWORD);
		} catch (SQLException e) {e.printStackTrace();}
		return con;
	}
	//关闭Connection
	public static void closeCon(Connection con){
			try {
				if(con!=null)
				con.close();
			} catch (SQLException e) {	e.printStackTrace();}
	}
	 //关闭PreparedStatemen
	public static void closePt(PreparedStatement pt){
			try {
				if(pt!=null)
				pt.close();
			} catch (SQLException e) {	e.printStackTrace();}
	}
	 //关闭ResultSet
	public static void closeRs(ResultSet rs){
			try {
				if(rs!=null)
				rs.close();
			} catch (SQLException e) {	e.printStackTrace();}
	}

	public static void main(String[] args)
	{
		Connection cc = DatabaseDAO.getConnection();
		System.out.println(cc);
	}
}

package com.java.role;

public class Users {
	private String memberID;        //用户账号
	private String name;	        //用户姓名
	private String password;	    //用户密码
	private String teamname;		//车队名称
	private String sex;		        //用户性别
	private int age;			    //用户年龄
    private String address;         //用户地址
    private String  phone;          //用户电话
    private String post;            //用户帖子
    private String grade;           //用户等级
	private String bicycletype;		//用户车型
	private String bicycleage;      //用户车龄


	public String getMemberID() {
		return memberID;
	}
	public void setMemberID(String memberID) {
		this.memberID = memberID;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getTeamname() {
		return teamname;
	}
	public void setTeamname(String teamname) {
		this.teamname = teamname;
	}
	public String getSex() {
		return sex;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getPost() {
		return post;
	}
	public void setPost(String post) {
		this.post = post;
	}
	public String getGrade() {
		return grade;
	}
	public void setGrade(String grade) {
		this.grade = grade;
	}
	public String getBicycletype() {
		return bicycletype;
	}
	public void setBicycletype(String bicycletype) {
		this.bicycletype = bicycletype;
	}
	public String getBicycleage() {
		return bicycleage;
	}
	public void setBicycleage(String bicycleage) {
		this.bicycleage = bicycleage;
	}



}
package com.java.users.DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;


import com.java.role.Users;

import com.java.Database.DatabaseDAO;

public class UsersDAO {
	private Connection con;
	private PreparedStatement pt;
	private ResultSet rs;

	public boolean login(Users users) {
		boolean flag = false;
		con = DatabaseDAO.getConnection();
		try {
			pt = con.prepareStatement("select * from member where memberID=? and password=?");
			// 设置参数
			pt.setString(1, users.getMemberID());
			pt.setString(2, users.getPassword());
			// 获取结果集
			rs = pt.executeQuery();
			// 如果能往下继续执行,表示用户名和密码正确
			if (rs.next()) {
				flag = true;
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			// 关闭数据库连接
			DatabaseDAO.closeRs(rs);
			DatabaseDAO.closePt(pt);
			DatabaseDAO.closeCon(con);
		}
		return flag;
	}


}

<?xml version="1.0" encoding="GBK" ?>

<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" 
	"http://struts.apache.org/dtds/struts-2.3.dtd">	 
<struts>
	<include file="struts-default.xml"></include>
	<package name="users" extends="struts-default" namespace="">
		<action name="login" class="com.java.action.LoginAction" method="login">
			<result name="success">/loginSuccess.jsp</result>
			<result name="input">/index.jsp</result>
		</action>
	</package>
</struts> 

40分
很简单啊,找不到result
重写了之后,一样的代码,不知道为什么就没问题了。。。。

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明java ee Could not find action or result