Programming Tutorials

Comment on Tutorial - Creating the first application using Struts 2 By Gokul Verma



Comment Added by : Trishul

Comment Added at : 2009-10-26 07:32:57

Comment on Tutorial : Creating the first application using Struts 2 By Gokul Verma
I got the sample and the test working. Thanks a lot. Here's web.xml for the sample:

<?xml version="1.0" encoding="UTF-8"?>

&lt;web-app id=&quot;WebApp_9&quot; version=&quot;2.4&quot; xmlns=&quot;<a href="http://java.sun.com/xml/ns/j2ee&quot;">http://java.sun.com/xml/ns/j2ee&quot;</a> xmlns:xsi=&quot;<a href="http://www.w3.org/2001/XMLSchema-instance&quot;">http://www.w3.org/2001/XMLSchema-instance&quot;</a> xsi:schemaLocation=&quot;<a href="http://java.sun.com/xml/ns/j2ee">http://java.sun.com/xml/ns/j2ee</a> <a href="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&quot;">http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&quot;</a>&gt;

&#160;&#160;&#160; &lt;display-name&gt;Struts Blank&lt;/display-name&gt;

&#160;&#160;&#160; &lt;filter&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;filter-name&gt;struts2&lt;/filter-name&gt;

&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;filter-class&gt;org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter&lt;/filter-class&gt;

&#160;&#160;&#160; &lt;/filter&gt;

&#160;&#160;&#160; &lt;filter-mapping&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;filter-name&gt;struts2&lt;/filter-name&gt;

&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;url-pattern&gt;/*&lt;/url-pattern&gt;

&#160;&#160;&#160; &lt;/filter-mapping&gt;

&lt;/web-app&gt;

Also,
struts.xml --&gt;

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;
&lt;!DOCTYPE struts PUBLIC

&#160;&#160;&#160; &quot;-//Apache Software Foundation//DTD Struts Configuration 2.0//EN&quot;

&#160;&#160;&#160; &quot;<a href="http://struts.apache.org/dtds/struts-2.0.dtd&quot;">http://struts.apache.org/dtds/struts-2.0.dtd&quot;</a>&gt;

&lt;struts&gt;

&#160;&#160;&#160; &lt;constant name=&quot;struts.enable.DynamicMethodInvocation&quot; value=&quot;false&quot; /&gt;
&#160;&#160;&#160; &lt;constant name=&quot;struts.devMode&quot; value=&quot;false&quot; /&gt;

&#160;&#160;&#160; &lt;!--
&#160;&#160;&#160; &lt;include file=&quot;example.xml&quot;/&gt;

&#160;&#160;&#160; &lt;package name=&quot;default&quot; namespace=&quot;/&quot; extends=&quot;struts-default&quot;&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;default-action-ref name=&quot;index&quot; /&gt;

&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;action name=&quot;index&quot;&gt;

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;result type=&quot;redirectAction&quot;&gt;

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;param name=&quot;actionName&quot;&gt;HelloWorld&lt;/param&gt;

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;param name=&quot;namespace&quot;&gt;/example&lt;/param&gt;

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/result&gt;

&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/action&gt;

&#160;&#160;&#160; &lt;/package&gt;

--&gt;

&#160;&#160;&#160; &lt;!-- Add packages here --&gt;

&#160;&#160;&#160; &lt;package name=&quot;default&quot; namespace=&quot;/&quot; extends=&quot;struts-default&quot;&gt;

&#160;&#160;&#160;&#160;&#160; &lt;action name=&quot;HelloWorld&quot; class=&quot;com.thinkbeyond.action.HelloWorld&quot;&gt;

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;result&gt;/HelloWorld.jsp&lt;/result&gt;

&#160;&#160;&#160;&#160;&#160; &lt;/action&gt;

&#160;&#160;&#160; &lt;/package&gt;

&lt;/struts&gt;


View Tutorial