Geting 404 error when request is made from JSP - struts2

I am trying to learn Struts2, but I am unable to create a working hello world application. It's giving a 404 (page not found) error when request is made from JSP. I kept all the lib files in the lib folder, placed struts.xml inside classes folder, but I am still getting this error.
Here is the view:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello World</title>
</head>
<body>
<form action="HelloWorld">
<input type="submit">
</form>
</body>
</html>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
This is my struts.xml file
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="default" extends="struts-default">
<action name="HelloWorld" class="vaannila.HelloWorld">
<result name="SUCCESS">/success.jsp</result>
</action>
</package>
</struts>
This is the error:
HTTP Status 404 - /Testi/HelloWorld
type Status report
message /Testi/HelloWorld
description The requested resource (/Testi/HelloWorld) is not available.
Apache Tomcat/6.0.33

This is the same question that you posted in Struts2 : Using form action just a bit more verbose.
You're problem is in the form tag you are using. It's not a struts form tag and the action attribute in a struts form tag is handled differently in a action attribute in an HTML tag.
I think my answer in Struts2 : Using form action should work for you.
PS: if you haven't changed your action extension, you may be able to make this work by simply adding a .action onto the end of your standard HTML tag action:
<form action="HelloWorld.action">
...
</form>

I would suggest to create a new folder under tomcat.webapps folder and place all your files according to the standards and give a try if you are using any IDE.
Try debugging from scratch,
first see if you are able to hit localhost:8080 sucessfully,
then try hitting a servlet(change the web.xml accordingly) to see if
you are able to go through.
Finally try hitting struts2 action. Make sure url-mapping you give is
correct.
I think this should be a mapping issue.

Can you post the error log content? and about the structure of the project.404indicatng the your server to able to locate the requested resources this can be a issue of your mapping or may be t unable to find the mapping file in class path.
you need to place struts.xml file in the class path so if you are using Eclipse just drop your struts.xml file inside src folder rest eclipse know how to handle this
Also the best way to learn struts2 is to download the sample applications from there official site
Example Applications:
this will help you to understand and learn struts2 better because
Sample application will help you to understand what structure one need to have
What all configuration files need to be placed and at what location
What are all required dependencies for a simple hello world application

Add imported lib to Action class
ex:
import com.opensymphony.xwork2.ActionSupport;
public class HelloWorldAction extends ActionSupport{
//....
//....
}

Related

Issue while upgrading to struts version 2.5.17

I am trying to upgrade struts version from 2.3.35 to 2.5.17 but I encountered an issue as below:
java.lang.NullPointerException
at com.opensymphony.xwork2.util.fs.StrutsJarURLConnection.getInputStream(StrutsJarURLConnection.java:170)
at com.opensymphony.xwork2.util.fs.JarEntryRevision.needsReloading(JarEntryRevision.java:84)
at com.opensymphony.xwork2.util.fs.DefaultFileManager.fileNeedsReloading(DefaultFileManager.java:65)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.needsReload(XmlConfigurationProvider.java:428)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.needsReload(StrutsXmlConfigurationProvider.java:163)
I have been using this guide to migrate to struts version 2.5.17:
https://cwiki.apache.org/confluence/display/WW/Struts+2.3+to+2.5+migration
I suspect it to be issue with tiles.
I have upgraded all struts related jar to version 2.5.17 including struts2-tiles-plugin. I have also upgraded all tiles related jars to 3.0.7.
Also I have removed the Xwork-core jar as from 2.5 xwork being merged to struts2-core jar.
Am I doing anything wrong.
Please note: I have not done any code changes as of now. The code works perfectly with struts version 2.3.35. But as soon as I have upgraded the struts version along with tiles version I started getting this issue.
Can some one please suggest If I am doing anything wrong?
Yes, there are supposed to be errors without code changes.
I don't think you are doing something wrong.
After adding the new .jars and removing the old ones it will only work when the code is compliant with the new framework.
Code changes would be:
.xml
Add the following <code> to web.xml.
<filter>
<filter-name>struts2</filter-name>
<filter-class> org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</web-app>
Change struts-config.xml to struts.xml and make following changes:
You can remove struts-config.xml completely and use annotations instead of .xml file.( since struts 2.5.17 )
<?xml version="1.0" encoding="ISO-8859-1" ?> <!-- change to UTF-8 -->
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd "> <!-- change to struts-2.5.dtd -->
<struts-config> <!-- change to <struts> -->
<!-- add <include file="struts-default.xml"/> -->
<form-beans>
<form-bean name="MyClassForm" type="forms.MyClassForm">
</form-bean>
</form-beans>
<action-mappings> <!-- change to <package name="hello-default" extends="struts-default"> -->
<action path="/MyClass" name="MyClassForm" type="actions.MyClassAction"
validate="false">
<action name = “MyClass” class = “actions.MyClass”>
<forward name="success" path="/Index.jsp"/>
<result> /Index.jsp </result>
</action>
</action>
</action-mappings> <!-- change to </package> -->
<message-resources parameter="resources"/>
</struts-config> <!-- change to </struts> -->
.java
Remove ActionForm.java files.
Properties are included in ActionSupport class which our Action class is supposed to extend.
Change Action.java
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class MyClassAction extends Action // change to ActionSupport {
//fields are now a property of the ActionSupport class
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
// change to public String execute() throws Exception {
MyClassForm input = (MyClassForm) form; // don't need this
input.setField1(“Hello”); // change to setMessage(“Hello”);
return mapping.findForward(“success”); // change to return Action.SUCCESS;
.jsp
Actions to be performed in this JSP are:
Replace <%# taglib %> directive
Use new set of tags defined by the struts-tags.tld
<%# taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Hello!</title>
</head>
<s:form action="submit.action" method="post">
<body>
<s:textfield label="Name" name=" field1" />
<s:property value="field1"/>
<s:submit" />
</body>
</s:form>
</html>
Cheers.
I got this resolved by upgrading struts version to 2.5.18. It also worked fine when I downgraded the struts version to 2.5.13.
But it is not recommended to use struts version between 2.5.16 and 2.3.36 (inclusive), so I have upgraded it to 2.5.18

Include struts 1 and Struts 2 in same web application [duplicate]

I am new to Struts 2 and I have been following a video tutorial on Struts 2(Koushik). I have created the Struts.xml, the action class and JSPs as same as created in the tutorial. But it gives the following exception.
Exception:
Jan 13, 2014 9:30:48 PM org.apache.struts2.dispatcher.Dispatcher warn
WARNING: Could not find action or result: /Struts2Starter/getTutorial.action
There is no Action mapped for namespace [/] and action name [getTutorial] associated with context path [/Struts2Starter]. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37)
at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:552)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="default" extends="struts-default">
<action name="getTutorial" class="org.koushik.javabrains.action.TutorialAction">
<result name="success">/success.jsp</result>
<result name="error">/error.jsp</result>
</action>
</package>
</struts>
Web.xml
<?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>Struts2Starter</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<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>
TutorialAction.java (Action class that I'm using)
package org.koushik.javabrains.action;
public class TutorialAction {
public String execute(){
System.out.println("Hello from execute");
return "success";
}
}
Project structure
success.jsp and error.jsp are normal jsp files with some text. I did a lot of things to resolve this issue by googling. But nothing didn't solve this. Please let me know if anyone knows what's behind this. I highly appreciate it. :)
Renaming Struts.xml naming convention to struts.xml will work.
The message from error clearly says that
no Action mapped for namespace [/] and action name [getTutorial]
associated with context path [/Struts2Starter]
This means that action configuration is not available at runtime. Check out the config-browser plugin to debug configuration issues.
To map correctly url to the action two parameters are required: the action name and namespace.
Struts loads xml configuration on startup and it should know the location of the struts.xml. By default it's looking on classpath to find a file with known name like struts.xml. Then it parses document and creates a runtime configuration. This configuration is used to find appropriate configuration element for the action url. If no such element is found during request, the 404 error code is returned with the message: There is no Action mapped for namespace and action name.
Also this message contains a namespace and action names used to find the action config. Then you can check your configuration settings in struts.xml. Sometimes the action name and namespace, stored in ActionMapping point to the wrong action. These values are determined by the ActionMapper which could have different implementation, used by plugins.
There's also another setting that might affect this mapper and mapping, but the point is the same if you get this message then URL is used didn't map any action config in runtime configuration. If you can't realize which URL you should use, you might try config-browser plugin to see the list of URLs available to use.
change your Struts.xml and put <constant name="struts.devMode" value="true" /> in struts.xml Development mode or devMode it enables extra debugging and helps indebugging
try below code
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/" extends="struts-default">
<action name="getTutorial" class="org.koushik.javabrains.action.TutorialAction">
<result name="success">/success.jsp</result>
<result name="error">/error.jsp</result>
</action>
</package>
</struts>
U just need to check that action name is constant everywhere...i also had same problem i resolved by removing namespace as it is not necessary which i see u have not mentioned and also i had different action name at loginpage.jsp and struts.xml page.. so just see ur action name
Your JSP file should not be under the WEB-INF folder, but should be under the web folder. I've attached an image to show you the right hierarchy.
Folder System

Struts 2 Portlet - redirectAction not working, doView() not called

I'm trying to create a simple Struts 2 JSR 286 Portlet, running on WebSphere Portal 7. I'm able to display a simple JSP that contains a link which calls an action and displays another JSP which accepts input. That works fine.
I start to run into problems, however, when I try to use a redirectAction. I don't see any error messages, but the redirect doesn't seem to work. The Portlet just shows a blank page.
In debugging this I noticed that the doView method of my Portlet class is never called, which seems very suspicious.
If anyone has experience developing Struts 2 Portlets on WebSphere Portal, I would appreciate some help in checking that my config files are correct. Have I missed something?
Here are the details:
WebSphere Portal 7.0.0.2
WebSphere Application Server 7.0.0.25
RAD 8.0.4
Struts 2.3.14.2
Windows 7
portlet.xml:
<?xml version="1.0" encoding="UTF-8"?>
<portlet-app id="com.ibm.demo.jsr286.TopUpPortlet.72594d5fe3"
version="2.0"
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
<portlet>
<description xml:lang="EN">Demo JSR 286 Struts Portlet</description>
<portlet-name>Demo Portlet</portlet-name>
<display-name>Demo Portlet</display-name>
<!-- DemoPortlet extends org.apache.struts2.portlet.dispatcher.Jsr286Dispatcher -->
<portlet-class>com.demo.jsr286.DemoPortlet</portlet-class>
<init-param>
<name>viewNamespace</name>
<value>/view</value>
</init-param>
<init-param>
<name>defaultViewAction</name>
<value>index</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<supported-locale>en</supported-locale>
<portlet-info>
<title>Demo Portlet</title>
<short-title>DemoPortlet</short-title>
<keywords>Demo Portlet</keywords>
</portlet-info>
</portlet>
<default-namespace>http://JSR286StrutsDemo/</default-namespace>
</portlet-app>
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>JSR 286 Struts Demo</display-name>
<servlet id="Struts2PortletDispatcherServlet">
<servlet-name>Struts2PortletDispatcherServlet</servlet-name>
<servlet-class>org.apache.struts2.portlet.dispatcher.DispatcherServlet</servlet-class>
</servlet>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="struts-plugin.xml"/>
<package name="view" extends="struts-portlet-default" namespace="/view">
<!-- This action works -->
<action name="index">
<result>/html/view/index.jsp</result>
</action>
<!-- This action works -->
<action name="startDemo">
<result>/html/view/demo.jsp</result>
</action>
<!-- This action does not work -->
<action name="redirectToIndex">
<result type="redirectAction">
<param name="actionName">index</param>
<param name="namespace">/view</param>
<param name="portletMode">view</param>
</result>
</action>
</package>
</struts>
* Update *
I've narrowed the problem down slightly. It looks like the action is being interpreted as a file location rather than a struts action. So, when I call action "redirectToIndex" it tries to display a page called "/view/index.action". I verified this by creating a file with that path and sure enough, the contents of that file are displayed in the portlet.
I feel that I'm probably missing some configuration option, but I'm not sure what. Servlet filter maybe? Can anyone help?
Actually you don't need doView method, because Jsr286Dispatcher is just a dispatcher. You can use actions like in ordinary Struts2 application.
From the documentation:
The portlet-class element is always org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher (or a subclass, if you have added some custom functionality). This is the portlet that acts as the dispatcher for the Struts 2 framework, and translates incoming user interaction to action requests that Struts 2 understands.
For jsr286 specification <portlet-class> should be org.apache.struts2.portlet.dispatcher.Jsr286Dispatcher and defaultViewAction init-param will call Struts2 action. And in struts.xml file, like usually, you can define action class + method to call.
So you need to define Jsr286Dispatcher as <portlet-class> and create action which you will use in struts.xml action definitions.
Also see this two links: http://struts.apache.org/development/2.x/docs/struts-2-portlet-tutorial.html and http://struts.apache.org/development/2.x/docs/portlet-plugin.html.

How to redirect root of the project to specific page in a Primefaces+JSF2.0 application using JBOSS 7

I have a Primefaces+JSF web site whose home page is
localhost:81/Mywebapp/login.jsf
I want to redirect the user to that home page if he goes to: localhost:81/Mywebapp/ so he doesnt need to write the complete URL.
How can I do that? I suppose it is some configuration in JBoss
Any help? thanks
Actually it should be in your web.xmlfile, try to put to it's end this entry
<welcome-file-list>
<welcome-file>/login.jsf</welcome-file>
</welcome-file-list>
EDIT
I also solved this once by making a new index.jsp like this
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>JSP Page</title>
</head>
<body>
<jsp:forward page="/login.jsf" />
</body>
</html>
Or put there a html file with this meta
<meta http-equiv="Refresh" content= "0; URL=login.jsf"/>
and set one of them as your welcome file. One of these solutions should do the job for you:-)
Sorry for the second answer, the formatting in the comments doesn't really cut it:
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
...
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
...
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
<url-pattern>*.jsf</url-pattern>
<url-pattern>subdir/*</url-pattern>
</servlet-mapping>
Peter's answer should work just fine, but if you're really concerned about the extensions (it doesn't really matter) then just add the places you want mapped under the servlet. This maps *.xhtml, *.jsf and anything under 'subdir/'.
If you had a hard file:
- index.xhtml
Myapp/index.xhtml and
Myapp/index.jsf
would map to the same file. xhtml is since your default suffix is xhtml
I hope this helps, honestly, with Primefaces 2 I'd definitely be using xhtml as that's the spec. With 3 it doesn't matter as much, but I still stay with xhtml as it isn't something I'd normally have on my server.
Best of luck (Petr's forwarding trick isn't a bad idea--it can really help in tough situations)
You can always do this with URL rewriting engines like PrettyFaces. You have to activate it in your web.xml and then define rewriting rules like this:
<url-mapping id="login">
<pattern value="/login" />
<view-id value="/legacy/user/login.xhtml" />
</url-mapping>
Because you mentioned explicitly login.jsf I think it's a good idea to think about including a security framework which is doing this (and many other things) for you. Seam security provides typesafe annotations for this:
#ViewConfig
public interface SeamPages
{
static enum Pages0
{
#ViewPattern("/jsf/admin/important.xhtml")
#UrlMapping(pattern="/admin/important")
#LoginView("/jsf/access/loginRequired.xhtml")
#AccessDeniedView("/jsf/access/accessDenied.xhtml")
#RestrictAtPhase(PhaseIdType.RESTORE_VIEW)
#LoggedIn
ENUM0;
}
}
This will solve three common requirements:
The URL /yourApp/admin/important will be redirected to the JSF page /jsf/admin/important.xhtml.
If the user is not #LoggedIn he will be redirect to /jsf/access/loginRequired.xhtml
IF the user does not have the rights to access the page he will be redirected to /jsf/access/accessDenied.xhtml

Struts 2.2.1 gives There is no Action mapped for namespace / and action name

I've got a simple Struts 2 application that I build and deploy to glassfish with Netbeans. When I point the web browser to http://localhost:8080/Struts2Hello/login.action/ it gives this error:
There is no Action mapped for namespace / and action name .
My action is named "login". Why does it think it is named "."?
(In order to get this far I've also had to add the javassist-3.7.ga to my lib/ directory. I'm not sure why, but that's what others have done to make Struts 2.2 work.)
Here's my web.xml and struts.xml files (yes, the struts.xml gets deployed to WEB-INF/classes):
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>Login.jsp</welcome-file>
</welcome-file-list>
<package name="default" extends="struts-default" namespace="/">
<action name="login" class="action.LoginAction">
<result name="success">Welcome.jsp</result>
<result name="error">Login.jsp</result>
</action>
</package>
Thanks.
Dean
My problem was that I had the .jsp files in the WEB-INF/ dir instead of one level higher. Strange error message for that problem, though.
In struts.xml(or any other struts config files included), content of mapping is back to the original Servlet/Jsp, i.e. you CAN NOT put .jsp files under WEB-INF. e.g. if the result in struts config file is: Welcome.jsp then you should put Welcome.jsp under the package root, like
Web-pages
...WEB-INF
...Welcome.jsp
...menu
......menu.xhtml
More often that not when struts gets the action name wrong even when there's nothing wrong with struts.xml, the problem is that the tag lib definition is missing from the jsp file.
crazy to answer this one after a year, but I had the same problem and I was pretty sure that I had mapped all my actions accurately, but it was showing the same error above....so I just cleaned the project and then ran it again..it worked perfectly fine...give it a try !
I encountered this so many times...so to avoid such kind of things, I just added "../eclipse.exe -clean" to the shortcut icon property....this works and u can forget about getting such kind of errors which is actually not an error....!

Resources