user471011
user471011

Reputation: 7386

Struts 2: Action result. How show in browser address line link on jsp?

For example on our index.jsp contains only one link:

<a href="<s:url action='viewBook'/>">Your Book</a>

In browser on index.jsp page I see this link:

http://localhost:8080/project/viewBook.action

when I click on this link opened page and in browser address line I see next address:

http://localhost:8080/project/viewBook.action

struts.xml contains next lines for action listTicket:

    <action name="viewBook" class="BookAction" method="view">
        <result>pages/book.jsp</result>
    </action>

My question: what I must change, that instead viewBook.action in browser I see link to the Page:

http://localhost:8080/project/book.jsp

I try set for result tag type="redirect". But in this case - page empty.

Upvotes: 1

Views: 1308

Answers (2)

Dave Newton
Dave Newton

Reputation: 160321

You won't see the backing view file shown in the URL, nor should you want to. View mechanics are an abstraction and not shown in essentially all MVC frameworks.

You'll see viewBook.action (assuming default action extension) if you redirect to the action using a "redirectAction" result type. This is the desired URL.

Upvotes: 3

user425367
user425367

Reputation:

You should not do this.
You want the url to link to your controller and not your jsp.

Upvotes: 3

Related Questions