我代表我的一位学生问这个问题 - “有谁知道如何将JSP Struts转换为Velocity Struts?”
I'm asking this on behalf of one of my students - "Does anybody have an idea how to convert JSP Struts to Velocity Struts?"
最满意答案
对于初学者来说, 你不需要一次完成所有事情 。 这很重要 - 只有在有时间测试页面时才应该转换页面,否则会得到一定程度的不良结果。 就个人而言,我通常不会这样做,只选择Velocity进行电子邮件模板。
您必须映射VelocityView servlet(在web.xml中):
<!-- Define Velocity template compiler --> <servlet> <servlet-name>velocity</servlet-name> <servlet-class> org.apache.velocity.tools.view.servlet.VelocityViewServlet </servlet-class> <init-param> <param-name>org.apache.velocity.toolbox</param-name> <param-value>/WEB-INF/toolbox.xml</param-value> </init-param> <init-param> <param-name>org.apache.velocity.properties</param-name> <param-value>/WEB-INF/velocity.properties</param-value> </init-param> </servlet> <!-- Map *.vm files to Velocity --> <servlet-mapping> <servlet-name>velocity</servlet-name> <url-pattern>*.vm</url-pattern> </servlet-mapping>您还需要创建toolbox.xml文件并放入任何要添加的工具,并创建velocity.properties ,与此文件的其他实例并无太大区别。
有关如何配置Velocity servlet的信息,请参阅VelocityStruts页面和VelocityView页面 。
For starters, you don't have to do it all at once. That's pretty important - you should only convert pages as you have time to test them or you will get some degree of a bad result. Personally, I don't generally do this, preferring Velocity for email templating only.
You have to map the VelocityView servlet (in web.xml):
<!-- Define Velocity template compiler --> <servlet> <servlet-name>velocity</servlet-name> <servlet-class> org.apache.velocity.tools.view.servlet.VelocityViewServlet </servlet-class> <init-param> <param-name>org.apache.velocity.toolbox</param-name> <param-value>/WEB-INF/toolbox.xml</param-value> </init-param> <init-param> <param-name>org.apache.velocity.properties</param-name> <param-value>/WEB-INF/velocity.properties</param-value> </init-param> </servlet> <!-- Map *.vm files to Velocity --> <servlet-mapping> <servlet-name>velocity</servlet-name> <url-pattern>*.vm</url-pattern> </servlet-mapping>You will also need to create the toolbox.xml file and put in any tools you want to add and create the velocity.properties, which isn't very different from other instances of this file.
See the VelocityStruts page and for overview and the VelocityView page for how to configure the Velocity servlet.
更多推荐
Struts,JSP,Velocity,知道,电脑培训,计算机培训,IT培训"/> <meta name="descri
发布评论