Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2 migration issue

 
David Erin
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

I am trying to get a sample application in struts 2 to work with my existing application which is struts 1.2. Here are the steps:

1) downloaded the necessary jars and added in /Webroot/WEB-INF
2) modified my web.xml to include :
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>

<filter-mapping><filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
3)Added struts.xml to WebRoot/WEB-INF/

<struts>
<include file="struts-default.xml"/>
<package name="bdr-emp2" namespace="/bdr-emp2">
<action name="test" class="com.bdr.emp.gruk.portals.actions.TestAction">
<result>http://localhost:8080/bdr-emp2/WEB-INF/jsp/test.jsp </result>
</action>
</package>
</struts>

The jsp is :

<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title><s:text name="HelloWorld.message"/></title>
</head>

<body>
<h2><s roperty value="message"/></h2>


</body>
</html>


The jsp is located in WebRoot\WEB-INF\jsp\test.jsp

The following error is thrown :
There is no Action mapped for namespace / and action name test

Can someone please advise what i am doing wrong?

Many thanks
 
David Erin
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone please provide any pointers as what i might be missing.

Thanks in advance
 
Eric Nielsen
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you're hitting the wrong URL to test...

1) What URL are you entering that generates this error?

(I would guess its something like localhost ort/<context>/test[<.suffix>])

2) However your "XWork Package" in the struts.xml file has configured a namespace, thus the the URL would have to be something more like
localhost ort/<context>/bdr-emp2/test[/<.suffix>]

This will cause it to look in the bdr-emp2 namespace instead of the default namespace.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic