I'm learning struts 2 from Java Brains. I've written a simple Hello world type struts 2 web application. It just shows an success page or error page. I've done everything instructed in the tutorial, but unfortunately the page is not loading. Following is the project explorer.
I've edited web.xml file like below.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Struts 2 Web Application</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
According to the tutorial, above web.xml configuration handovers the whole request response process to struts. I've configured struts.xml file like following.
<?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" extends="struts-default">
<action name="getTutorial" class="action.TutorialAction">
<result name="success">/success.jsp</result>
<result name="failure">/error.jsp</result>
</action>
</package>
</struts>
I've written action.TutorialAction
class like following.
package action;
public class TutorialAction {
public String execute(){
System.out.println("Hello From execute");
return "success";
}
}
After running the project under Tomcat 7, the url "http://localhost:8080/Struts2Starter/getTutorial.action" should load success.jsp page. But it's showing 404 error.
success.jsp page is just a .jsp page.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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>Insert title here</title>
</head>
<body>
Success Page
</body>
</html>
I'm clueless why it's not running. I've been banging my head to solve it for a week and at last it just no hope :( . Help me please, Thanks in advance.