I am studying a Struts2. And I have struts.xml
file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="default" namespace = "/" extends="struts-default" >
<action name="loginStudent" class = "org.dream.action.LoginAction">
<result name="login">/login.jsp</result>
<result name="success">/index.jsp</result>
<result name="input">/login.jsp</result>
</action>
</package>
</struts>
I have my LoginAction.class
:
package org.dream.action;
import org.apache.commons.lang3.StringUtils;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction implements Action {
private String studentId;
private String password;
public String execute(){
if(getStudentId().equals("test")||getPassword().equals("test")){
return SUCCESS;
}else return LOGIN;
}
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
And I have jsp files.
Login.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ 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=ISO-8859-1">
<title>Login Page</title>
</head>
<body>
<s:form action="loginStudent">
<s:textfield key="studentId" label="Student Id"/>
<s:textfield key="password" label="Password"/>
<s:submit/>
</s:form>
</body>
</html>
When I press sumbit button I get an error:
HTTP Status 404 - There is no Action mapped for namespace [/] and action name [loginStudent] associated with context path [/Struts2Demo]
I can't find a reason of this error, please help me!!