Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Not A Problem
-
2.1.6
-
None
-
None
-
WinXP, Struts 2.1.6, Velocity 1.6, Velocity-tools 1.4
Description
Hi. Please help me because I'm loosing my nerves on it....
I decided to build my aplication in Struts2 using Velocity.
I downloaded latest versions of both. Ok, simple HelloWorld build with velocity works fine...
I also wanted to use some velocity tools such as date formatting and Struts field or error messages so I installed velocity-tools 1.4.
I've made the toolbox.xml and put it in the WEB-INF I also made some corrections in web.xml...
Aplication starts without any errors but none of tools is working :/
this is a part of my .vm template
<h2>#if( $messages.exist() )
#foreach( $e in $messages.all )
$e <br>
#end
#end
$message
</h2>
<p>Current date and time is: <b>$currentTime</p>
<p>sformatowana $date.format("yyyy-MM-dd",$currentTime)</p>
and it looks like:
Current date and time is: Sat Mar 28 00:15:06 CET 2009
sformatowana $date.format("yyyy-MM-dd",$currentTime)
as you can see velocity tools arent working.
I also find some topics on forums and some solutions like: https://issues.apache.org/struts/browse/WW-2796
but it didn't help
MY FILES:
struts.xml
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.locale" value="en_GB" />
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" />
<constant name="struts.velocity.manager.classname" value="MyVelocityManager" />
<package name="start" extends="struts-default">
<action name="start">
<result type="velocity">/pages/start.vm</result>
</action>
<action name="rejestracjaShow">
<result type="velocity">/pages/rejestracja.vm</result>
</action>
<action name="rejestracja" class="Rejestracja" >
<result type="velocity" name="success">/pages/rejestracja.vm</result>
<result type="velocity">/pages/rejestracja.vm</result>
</action>
</package>
<package name="roseindia" namespace="/roseindia" extends="struts-default">
<action name="HelloWorld" class="HelloWorld">
<result type="velocity">/pages/HelloWorld.vm</result>
</action>
<action name="showLogin">
<result>/pages/login.vm</result>
</action>
<action name="doLogin" class="Login">
<result type="velocity" name="input">/pages/login.vm</result>
<result type="velocity" name="error">/pages/login.vm</result>
<result>/pages/loginsuccess.jsp</result>
</action>
</package>
</struts>
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
toolbox.xml
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0"?>
<toolbox>
<tool>
<key>link</key>
<scope>request</scope>
<class>
org.apache.velocity.tools.struts.StrutsLinkTool
</class>
</tool>
<tool>
<key>msg</key>
<scope>request</scope>
<class>
org.apache.velocity.tools.struts.MessageTool
</class>
</tool>
<tool>
<key>errors</key>
<scope>request</scope>
<class>
org.apache.velocity.tools.struts.ErrorsTool
</class>
</tool>
<tool>
<key>form</key>
<scope>request</scope>
<class>
org.apache.velocity.tools.struts.FormTool
</class>
</tool>
<tool>
<key>tiles</key>
<scope>request</scope>
<class>
org.apache.velocity.tools.struts.TilesTool
</class>
</tool>
<tool>
<key>validator</key>
<scope>request</scope>
<class>
org.apache.velocity.tools.struts.ValidatorTool
</class>
</tool>
</toolbox>
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
HelloWolrd.vm
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
<html>
<head>
<title>Struts 2 Hello World Application!</title>
</head>
<body>
VELOCITY
<h2>#if( $messages.exist() )
#foreach( $e in $messages.all )
$e <br>
#end
#end
$message
</h2>
<p>Current date and time is: <b>$currentTime</p>
<p>sformatowana $date.format("yyyy-MM-dd",$currentTime)</p>
Time $Dzis.getHours():$Dzis.getMinutes():$Dzis.getSeconds()
Date $Dzis.getDate()/$Dzis.getMonth()/$Dzis.getYear()
</body>
</html>