Hi, I'm new to struts and liking what I've seen so far. I'm building a toy
application to learn the framework (A simple blogging app). I have an action
with a view() method that returns the string "view". What happens is that a
link is clicked to view details about a particular blog, and a request
parameter is sent (get request) to my BlogService action's view method. The
url for a particular blog is created by iterating through a collection
retrieved from the database. The urls for each blog end up looking like
"/BlogService.action!view?id=1" (the number changes depending on which link
was clicked).

My prepare method sees that there is a parameter named "id" and looks up the
info from the database, and populates my blog object. As stated before the
view() method returns "view" and in my struts.xml I have this defined:

<action name="BlogService" class="BlogService">
   <result>blog/Blogs.jsp</result>
   <result name="input">blog/Blog_edit.jsp</result>
   <result name="view">blog/Blog_view.jsp</result>
</action>

<action name="*">
   <result>/{1}.jsp</result>
</action>

So my blog/Blog_view.jsp is the view that is rendered. Everything works as
expected, but I noticed that when the Blog_view view is rendered, my
navigation links now have that request parameter appended to them when the
don't need it. Here's an example of the code I'm using for my navigation:

<li><a href="<s:url action="index" />">Home</a></li>
<li><a href="<s:url action="About" />">About</a></li>

Now before I click a link that takes me to the "Blog_view.jsp", the code
above renders as a link to "/index.action" & "/about.action" which will
really just render "index.jsp" & "about.jsp" since there are no action
classes behind them (setup by the action name="*" in my struts.xml file).

But after I click a link that takes me to the "Blog_view.jsp" the navigation
links are rendered as "/index.action?id=1" & "/about.action?id=1" (the
number changes based on the previously requested id). Now the links still
work, and currently it isn't hurting anything, but I think that maybe I've
gone wrong somewhere, and I'm not too happy about that fact that the request
parameters are sticking around.

Please let me know if I didn't make any sense, or if I need to provide more
detail.
Any help is greatly appreciated.

Thanks,
Will

Reply via email to