JSP Struts转换为Velocity Struts(JSP Struts to Velocity Struts conversion)

编程入门 行业动态 更新时间:2024-10-25 16:23:07
JSP Struts转换为Velocity Struts(JSP Struts to Velocity Struts conversion)

我代表我的一位学生问这个问题 - “有谁知道如何将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

本文发布于:2023-08-04 07:58:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1412439.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   Struts   JSP   Velocity   conversion

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!