哪位大侠整过struts2整合velocity啊?求指点??
这是我的struts.xml文件
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN" "http://struts.apache.org/dtds/struts-2.1.7.dtd"> <struts> <constant name="struts.devMode" value="false"/> <constant name="struts.configuration.xml.reload" value="true"/> <package namespace="/" name="" extends="struts-default"> <action name="velocity" class="com.sanjiawu.action.VelocityAction"> <result name="success">HelloVelocity.vm</result> </action> </package> </struts>
web.xml文件
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <filter> <filter-name>Struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>Struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <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> <load-on-startup>10</load-on-startup> </servlet> <servlet-mapping> <servlet-name>velocity</servlet-name> <url-pattern>*.vm</url-pattern> </servlet-mapping> </web-app>怎么找不到 The requested resource (/HelloVelocity.vm) is not available.抱这种错呢??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好了,老大,是把这句话resource.loader = file删掉就ok了,非常感谢!!
velocity.properties文件
input.encoding=UTF-8
output.encoding=UTF-8
resource.loader = file
file.resource.loader.path=D:\myworkspace\struts\WebRoot
webapp.root.url=http://192.168.12.48:8080
webapp.template.path=D:\myworkspace\struts\WebRoot
是这样写的,