Reputation: 21
I'm learning Struts 2 for a project requirement and I've met some issues.
Following this tutorial at:
http://www.mkyong.com/google-app-engine/google-app-engine-struts-2-example/
And what I've done extra:
Changed web.xml to
<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<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>
<listener>
<listener-class>com.mkyong.listener.Struts2ListenerOnGAE</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Now, when I rebuild and loads
http://localhost:8888
Rather then seeing the content I should have in my index.jsp, I'm getting a
Error 404 There is no Action mapped for namespace [/] and action name [] associated with context path [].
Can someone point me to the right direction? I've seen some other similar questions in SO but their solutions do not work for this specific example of Struts 2 + GAE.
My struts.xml
<struts>
<package name="user" namespace="/User" extends="struts-default">
<action name="Login">
<result>pages/login.jsp</result>
</action>
<action name="Welcome" class="com.mkyong.user.action.WelcomeUserAction">
<result name="SUCCESS">pages/welcome_user.jsp</result>
</action>
</package>
</struts>
Folder structure
I cant post images so, http://i.imgur.com/KSPmaMr.png
Exact same libraries used for download
http://www[dot]mediafire[dot]com/?utliwvcmo63o8l7
Upvotes: 1
Views: 624
Reputation: 2770
@Eleazar I followed the mykong tutorial link that you mentioned in your question. There is no use of index.html
as far as I see that tutorial. <welcome-list>
file is used when the is no action mentioned on application startup.
On step:8 in that tutorial they has provided the url
which is http://localhost:8888/User/Login.action
you need to run the test. Its got nothing to do with file in welcome list...
UPDATE:
You are getting that error because you have added struts2 filter as /*
, and your action namespace is for /User
. There is not action namespace for /
. Adding package with name="default" with namespace="/" i.e <package name="default" extends="struts-default" namespace="/"></package>
will resolve you issue. It will hit <welcome-file>
Upvotes: 1
Reputation: 2390
ok ,i got your problem,
change your struts.xml to this
<struts>
<package name="default" extends="struts-default" namespace="/">
<action name="Login">
<result>pages/login.jsp</result>
</action>
<action name="Welcome" class="com.mkyong.user.action.WelcomeUserAction">
<result name="SUCCESS">pages/welcome_user.jsp</result>
</action>
</package>
</struts>
I guess this will work, because filterDispatcher search for struts.xml file in root folder if you put your struts.xml file in root directory.
Upvotes: 1