Question

I'm working a Struts2 Web Application. Everything was running fine. All actions are getting mapped properly and the application correctly redirects to pages. However, when I do the SAME for this particular module (related to File Upload), it just FAILS! I don't understand what's wrong, I've tried various combos of "/" and all and I still can't get the page to re-direct. What am I doing wrong?

My 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">
     -->
    <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" 
    "http://struts.apache.org/dtds/struts-2.1.dtd">


<struts>
    <constant name="struts.enable.DynamicMethodInvocation"
        value="false" />
    <constant name="struts.devMode" value="false" />
    <constant name="struts.custom.i18n.resources"
        value="ApplicationResources" />

    <package name="default" extends="struts-default" namespace="">
        <action name="login" class="com.proconsulto.action.LoginAction" method="execute">
            <result name="success">/Dashboard.jsp</result>
            <result name="failure">/SignIn.jsp</result>
           </action>

           <action name="signup" class="com.proconsulto.action.UserAction" method="addUser">
            <result name="success">/Dashboard.jsp</result>
            <result name="failure">/SignIn.jsp</result>
           </action>

            <action name="logout" class="com.proconsulto.action.LoginAction" method="logout">
            <result name="success">/SignIn.jsp</result>
            </action>

           <action name="placerequest" class="com.proconsulto.action.PlaceRequestAction" method="placeRequest">
           <result name="success">/Success.jsp</result>
           </action>

    </package>
</struts>

And the form from where it should redirect:

<s:form theme="simple" action="placerequest.action" enctype="multipart/form-data" method="post">
            <ul style="list-style-type:none;">
            <li class="field"><p id="qaz">Headline : <br/><s:textfield style="width:550px;align:center;display:inline;" name="headline" cssClass="text input"></s:textfield></li>
            <li class="field"><p id="qaz">Description :<br/> <s:textarea style="width:550px;display:inline;align:center;" name="description" cssClass="textarea input"></s:textarea></li>
            <li class="field"><p id="qaz">File Upload (if any) :<br/> <s:file style="height:auto;width:550px;display:inline;align:center;" name="userImage" cssClass="text input" /></li>
            <div class="medium default btn"><s:submit value="Proceed"/></div>&nbsp;&nbsp;
            <div class="medium default btn"><s:reset value="Reset"/></div>

placerequest is the action which just won't get mapped!

Please help.

Complete error message:

type Status report

message There is no Action mapped for namespace [/] and action name [placerequest] associated with context path [/ProConsulto].

description The requested resource (There is no Action mapped for namespace [/] and action name [placerequest] associated with context path [/ProConsulto].) is not available.

Was it helpful?

Solution

You should add a namespace to the package, like namespace="/". But if you want to stick with namespace="" (that could create problems and/or unattended results), you can try to specify it in the form:

<s:form action="placerequest.action" namespace="" ... >

Also, for test purposes only, include in your project the Struts2 Config Browser plugin, to see how actions are mapped (browse them with the left menu).

enter image description here

Remember to remove it before releasing to production ;)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top