Action in Struts2 Application
I had a sample HelloWorld Example of Struts 2 from web.
Its struts.xml contains:
<struts>
<package name="default" extends="struts-default">
<action name="HelloWorld">
<result>/success.jsp</result>
</action>
</package>
</stru开发者_Go百科ts>
On running application, I get a warning stating that:
No configuration found for the specified action: 'HelloWorld' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
So, on clicking of submit button in index.jsp page, I get Http 404 error(requested resource is not avaiable) error.
You are coding with the help of vaannilla example that is found on web with Struts2 keyword on Google search.
Are you using any development tool for coding? At least in Eclipse you can create an empty dynamic web project and then at least you have correct file structure, correctly formed xml templates and so on.
You have to follow the tutoarial strictly, not leaving anything out and having all files in correct locations. Also xml files on that example are missing some "title" type of rows that can be copied from the template of Eclipse's hello world example or similar.
But if you don't want to stick inside the vaannilla solution, the struts2 official Hello World tutorial has more comprehensive approach on their one. At least there are entire xml files present.
I got this problem quite often. so because my application does not refresh correctly. So i clean my project and the problem is solved. Go to 'Project' and select 'Clean...'.
精彩评论