Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

SwitchAction

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone pls provide some help rgding SwitchAction? I am not becoming able to work it out.I 've defined two configuartion files , namely -
1. web.xml < Code fragment >

<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>


<init-param>
<param-name>config/admin</param-name>
<param-value>/WEB-INF/struts-config-admin.xml</param-value>
</init-param>

1. struts-config.xml
<action-mappings>
<action
path ="/switch"
type ="org.apache.struts.actions.SwitchAction">
</action>
<action path="/Login123"
name="loginBean"
type="com.action.LoginAction"
input="/jsp/login.jsp"
scope="request"
className=
"com.customMapping.MyActionMapping"
parameter ="method">
<set-property property = "logResults" value = "true" />
<forward name="success"
path="/switch.do?page=/login.do&prefix=/admin"
/>
</action-mappings>

2. Now I ve defined struts-config-admin.xml as follows-

<action
path = "/switch"
type= "org.apache.struts.actions.SwitchAction" />

<action
path = "/admin/login"
name = "loginBean"
type = "com.action.admin.LoginAction"
>
<forward name = "success" path = "/jsp/switchAction.jsp" />
</action>


Now after creating this I am not getting the output.

Regards-
Anirban, Jnior member<SCJP>
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, the path to your second action in struts-config-admin.xml should be /login instead of /admin/login.

Secondly, According to Struts javadoc, when using this action you have to provide a page parameter and a prefix parameter. Are you doing this?

For example, if you're currently in the main module and you want to switch to the admin module login page, the url would be switch.do?prefix=/admin&page=/login.

Of course, if you're in the main module, you can also accomplish the same thing by calling admin/login.do
 
reply
    Bookmark Topic Watch Topic
  • New Topic