Re: Struts question: Calling Action by URL
"Joerg Gippert" <Joerg.Gippert@arcor.de> schrieb im Newsbeitrag
> Hello everyone!
Ok, found the mistake. Just replying to myselfe, in case someone else runs
in to the same mistake and does a Google search on that topic. Hereīs what I
Using the following line in the global-fowards section, will cause Struts to
look for an action whose path is 'ShowItemDetAction':
<forward name="showdetails" contextRelative="true"
Thus, I added an action mapping that looks like this:
The JSP still looks like this:
<html:link forward="showdetails" paramId="iid" paramName="ITEMS"
<bean:write name="ITEMS" property="itemid" />
<bean:write name="ITEMS" property="name" />
which produces an output of links like: http://127.0.0.1/myapp/test.do?iid=6
Clicking on that link envokes the actionservlet 'ShowItemDetAction'. The
parameter 'iid' can be accessed by something like:
String iids = request.getParameterValues("iid");
String id = iids; //id would be '6' according to link stated above
Make sure to catch an empty array.
> Iīm trying to call an actionsverlet by an URL in order to pass a parameter
> to the actionservlet. I have an jsp, that list a couple of items. By
> clicking on a link next to the item, another JSP should be opened with the
> itemīs details. The item list JSP looks like that:
> <logic:iterate id="ITEMS" name="ITEM" property="list">
> <html:link forward="showdetails" paramId="iid" paramName="ITEMS"
> <bean:write name="ITEMS" property="itemid" />
> <bean:write name="ITEMS" property="name" />
> This works fine. The links produced by this JSP look like this:
> When I click on such a link, I get the following error:
> HTTP Status 400
> type Status report
> message Invalid path /ShowItemDetAction was requested
> description The request sent by the client was syntactically incorrect
> (Invalid path /ShowItemDetAction was requested).
> In my Struts-config file, I wrote this:
> <forward name="showdetails" contextRelative="true"
> path="/ShowItemDetAction.do" redirect="true"/>
> In the same config file, there are also some action mappings. If I call
> those actionservlets by an url (eg. "/addItem.do") it works without any
> problem. The classfiles are all in the right place (ShowItemDetAction
> I had a look at the apache struts websiteīs userguide and I canīt see what
> Iīm doing wrong. Anyone here who has a hint for me? Any help is greatly
> Thanks in advance,
|All times are GMT. The time now is 01:19 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.