I've been trying to no avail to set up a simple Struts2 application so I can get on with learning the framework. Basically, what I am expecting to happen is that when an action is triggered that isn't defined, then a default page will be displayed.
This app is being developed in Eclipse.
I have a very simple struts.xml file set up in the WEB-INF/classes directory:
<struts>
<!-- Include webwork default (from the Struts JAR). -->
<include file="struts-default.xml" />
<!-- Configuration for the default package. -->
<package name="default" extends="struts-default">
<action name="*">
<result>/test.jsp</result>
</action>
</package>
</struts>
I have the test.jsp file (just the default jsp template that gets created in Eclipse, ie "Insert title here") at the WebContent level, and the welcome page (which triggers the action) is index.jsp is also at that same level and gets displayed at program startup. It is defined as follows:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>GlassFish JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<s:form action="other">
<s:submit value="Submit" />
</s:form>
</body>
</html>
I've also tried this with other action names, and no matter what, I get back a 404 page not found. I've tried this on both GlassFish and Websphere 6.1.1 with the same results, leading me to suspect that there is something I am missing that is probably right in front of me involving either directory structure (are the paths relative to the struts.xml file or the context root?) or some configuration file.
After some trying, I was able to get this up and running on Eclipse Ganymede on Mac OS X 10.5.6 using Glassfish, but I'm still having no luck with IBM Websphere and Application Server Toolkit (an Eclipse derivative) on Windows XP. I am a bit suspicious that this might have something to do with the browser.
I just tried adding a file called "other.action" to the same directory as my other JSP files mentioned above. Now when I click on the submit button that is linked to the "other" action, the action proceeds successfully to my test.jsp page. I may be incorrect, but I don't believe that I should have to give a file named "someaction.action" for every possible "someaction" that I may need to use (I know I didn't need it on the OS X run of my app).
More updates - I just tried it on Firefox 3.5.2 and running on that browser gave the same results - file not found without the "other.action" file on Websphere, so now I suspect it is a Websphere configuration issue.