Re: Struts question: Calling Action by URL

J

Joerg Gippert

Joerg Gippert said:
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
did wrong:

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"
path="/ShowItemDetAction.do" redirect="true"/>

Thus, I added an action mapping that looks like this:

<action path="/ShowItemDetAction"
type="com.mycompany.struts.action.ShowItemDetAction"></action>

The JSP still looks like this:
<html:link forward="showdetails" paramId="iid" paramName="ITEMS"
paramProperty="itemid">
<bean:write name="ITEMS" property="itemid" />
<bean:write name="ITEMS" property="name" />
</html:link>

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[0]; //id would be '6' according to link stated above

Make sure to catch an empty array.

Regards,
Joerg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top