struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Duan, Bin" <BD...@claritas.com>
Subject RE: Problem getting request parameters in HTTP GET in Struts 2
Date Tue, 17 Mar 2009 20:21:38 GMT
Musachy,

The web.xml is very simple since we just started this project. Here it is. Please advise:


<?xml version = '1.0' encoding = 'windows-1252'?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee">
    <description>New MMS Website</description>

    <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>240</session-timeout>
    </session-config>
    <mime-mapping>
        <extension>html</extension>
        <mime-type>text/html</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>txt</extension>
        <mime-type>text/plain</mime-type>
    </mime-mapping>    
</web-app>

-----Original Message-----
From: Musachy Barroso [mailto:musachy@gmail.com] 
Sent: Tuesday, March 17, 2009 4:17 PM
To: Struts Users Mailing List
Subject: Re: Problem getting request parameters in HTTP GET in Struts 2

Something is very wrong in your configuration. Can you post your web.xml?

musachy

On Tue, Mar 17, 2009 at 3:50 PM, Duan, Bin <BDuan@claritas.com> wrote:
> Thanks for the response.
>
> I did that. The request obtained by implementing RequestAware is the same as the one
obtained from ServletActionRequest.getRequest().
>
> None of them worked. Actually, I did get the parameter map from the request, and it contained
null data.
>
> Have you tried the scenario, did it work for your application?
>
> -----Original Message-----
> From: Struts Two [mailto:strutstwo@yahoo.ca]
> Sent: Tuesday, March 17, 2009 3:46 PM
> To: Struts Users Mailing List
> Subject: Re: Problem getting request parameters in HTTP GET in Struts 2
>
>
> Why do n't you let your action implement RequestAware interface and then get parameter
from the request map.
>
> --- On Tue, 3/17/09, Duan, Bin <BDuan@claritas.com> wrote:
>
>> From: Duan, Bin <BDuan@claritas.com>
>> Subject: Problem getting request parameters in HTTP GET in Struts 2
>> To: user@struts.apache.org
>> Received: Tuesday, March 17, 2009, 7:01 PM
>> I was trying to get a parameter from
>> a Http GET. The get from jsp looks
>> like this:
>>
>> <a
>> href=/providerDetail.action?drProviderId=1000>Provider
>> Name
>>
>> The providerDetail.action maps to ProviderAction class. In
>> the action
>> class, I have a setDrProviderId() method, but found the id
>> was not set.
>> Then I tried to get the id from
>> ServletActionRequest.getRequest().getParameter("drProviderId"),
>> but
>> still did not get anything.
>>
>>
>>
>> I debugged the code, in the request object, I saw request
>> input as "GET
>> /providerDetail.action?drProviderId=1000", this pretty much
>> meant the
>> parameter was sent to the server side correctly. But
>> request.getParameter("drProviderId") returned me null.
>>
>>
>>
>> If I switch to use form POST, my setDrProviderId() method
>> was still NOT
>> called, but I could get the id from
>> request.getParameter("drProviderId").
>>
>>
>>
>> This problem will almost be a show stopper for our project
>> to use
>> Struts. Anybody has any ideas of what could be wrong?
>>
>>
>>
>> I am using Struts 2.1.6. I tried both on oc4j and JBoss.
>>
>>
>>
>>
>>
>>
>>
>> Following is my struts.xml file
>>
>>
>>
>>
>>
>> <struts>
>>
>>
>>
>>     <package name="dataReceiving"
>> extends="struts-default">
>>
>>
>>
>>         <action name="listProvider"
>> method="listProvider"
>>
>>
>> class="com.claritas.mms.radish.dataReceiving.DrProviderAction">
>>
>>
>> <result>/dataReceiving/ProviderList.jsp</result>
>>
>>         </action>
>>
>>         <action
>> name="providerDetail" method="providerDetail"
>>
>>
>> class="com.claritas.mms.radish.dataReceiving.DrProviderAction">
>>
>>
>> <result>/dataReceiving/ProviderDetails.jsp</result>
>>
>>         </action>
>>
>>     </package>
>>
>>
>>
>> </struts>
>>
>>
>>
>> Following is my DrProviderAction class
>>
>>
>>
>>     public void setDrProviderId(String id)
>>
>>     {
>>
>>         this.drProviderId = new
>> Integer(id).intValue();
>>
>> }
>>
>>
>>
>>     public String providerDetail()
>>
>>     {
>>
>>         Map map =
>> request.getParameterMap();
>>
>>
>>
>>         String sid =
>> request.getParameter("drProviderId");
>>
>>         drProviderId = new
>> Integer(sid).intValue();
>>
>>         //check if the
>>
>>         if(session != null)
>>
>>         {
>>
>>             Map<Integer,
>> DrProvider> providerMap =
>> (Map)session.get("provider_map");
>>
>>             if(providerMap !=
>> null)
>>
>>             {
>>
>>
>> provider = providerMap.get(drProviderId);
>>
>>             }
>>
>>
>>         }
>>
>>         else //go to database
>>
>>         {
>>
>>             provider =
>> service.getProvider(drProviderId);
>>
>>         }
>>
>>
>>
>>         return SUCCESS;
>>
>>
>>
>>     }
>>
>>
>>
>>
>>
>>
>
>
>      __________________________________________________________________
> Instant Messaging, free SMS, sharing photos and more... Try the new Yahoo! Canada Messenger
at http://ca.beta.messenger.yahoo.com/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message