• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[solved] struts 2 mapping for .action

 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can struts 2 do a mapping such as when the user goes to http://localhost:8080/tutorial
the framework fills in defaultUserChosenActionClassMapping.action so that it runs the execute method on the action class w/o going through
another page containing <META HTTP-EQUIV="Refresh" CONTENT="0;URL=classAction.action"> ?
What other alternatives are to do it like just with struts 2 if any?


 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I couldn't understand your problem properly, but if you want to redirect from an action to another, then there is a redirect action result that you can use...
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i first enter the app, i need to do a html refresh to not directly type classAction.action at the end of the URL.
I wondered if there's a way to do a struts 2 mapping to type in the application path localhost/app and struts would autocomplete from the mapping the classAction.action like:
http://localhost/app/classAction.action
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could just not use the ".action" suffix, I suppose. Or just use the RESTful mapper, which in my opinion is less error-prone.
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, what i want to achieve is typing http://localhost:8080/appname
and the application displaying main.jsp
so far i managed to get it work with:
http://localhost:8080/appname/main
http://localhost:8080/appname/mainAction
http://localhost:8080/appname/mainAction.action

However i can't achieve the effect with just the appname with these (with or without the result name="success"):

Do you know why, or how should they look to achieve the desired effect please?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh; you just want a welcome page? That's in web.xml, and has nothing to do with Struts (although you might need to make sure that forwards are also mapped to the filter--I don't recall).
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's exactly the problem, if i use the welcome page, the Action class associated with it doesn't run.
I need the Action class because i'm using s:property that sets some stuff in the page, and s:property doesn't work of course if the action class doesn't.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Other people are using actions as welcome files; some (all?) of them may have had to change the types of requests handled by the filter. Some servers require a physical file even if the request is served by an action. This is a server issue, not Struts.

The struts-user mailing list has had several threads about this over the years; I'd suggest starting your search there if you're not having good luck with a full-web search.
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, welcome-file accepts actions, i didn't know it can, thanks! That solves my problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic