Like velocity-tools, we focus on the front-end integrated solution.
This is a sub project of jello
Like velocity-tools, we focus on the front-end integrated solution.
Like velocity-tools, we focus on the front-end integrated solution.
This is a sub project of jello
目前支持jsp和velocity,感觉如果要支持freemarker参照velocity应该也不难,为啥不支持一下呢?
我看你的代码,只有在Html指令中才会去替换掉这类占位符,所以如果是在异步请求的页面中,是不需要Html标签的,所以在里面异步引用资源,如:
#script
require(['../form'])
#end
详情见jello-demo中的page/examples/partial/form.vm
文件,通过ajax请求该页面时,引用的js不能被正确的识别,当然可以使用#require直接引用。所以不知道是bug呢,还是确实是不需要在异步的页面里进行异步的资源引用?
请参考https://github.com/sxpujs/fis-velocity-tools-update
主要就是JSONDirective这个类,个人感觉可以加到基础框架中。
版本: fis-velocity-tools-2.11.jar
bug 代码位置:com.baidu.fis.servlet.ListenerTask.java 67行
for (int i = 0; i < currentFiles.length; i++) {
if (Arrays.binarySearch(filelist, currentFiles[i]) > -1){
File file = new File(path, currentFiles[i]);
// System.out.println("Check " + file.toPath());
if (file.exists() && isFileUpdated(file)) {
setRefresh();
System.out.println(currentFiles[i]+" changed");
break;
}
}else{
System.out.println("File " + currentFiles[i] + " has be created.");
setRefresh();
filelist = currentFiles;
break;
}
}
//请事先Arrays.sort(filelist)再Arrays.binarySearch
//建议去除System.out代码
如http://fis.baidu.com/fis3/docs/node-mock.html 所示,支持如下mock指令
proxy ^\/api\/(.*)$ http://127.0.0.1:7777/api/$1
看pom.xml已经到2.8了, 可release只到1.8。
和spring结合的demo也好久没更新了。
刚使用jello
spring的配置,resourceLoaderPath配置如下
<bean id="fisInit" class="com.baidu.fis.velocity.spring.FisBean"/>
<bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="resourceLoaderPath" value="/WEB-INF/views/"/>
<property name="velocityProperties">
<props>
<prop key="input.encoding">utf-8</prop>
<prop key="output.encoding">utf-8</prop>
<!--<prop key="resource.loader">file</prop>-->
<!--<prop key="file.resource.loader.path">/</prop>-->
<prop key="userdirective">
com.baidu.fis.velocity.directive.Html, com.baidu.fis.velocity.directive.Head,
com.baidu.fis.velocity.directive.Body, com.baidu.fis.velocity.directive.Require,
com.baidu.fis.velocity.directive.Script, com.baidu.fis.velocity.directive.Style,
com.baidu.fis.velocity.directive.Uri, com.baidu.fis.velocity.directive.Widget,
com.baidu.fis.velocity.directive.Block, com.baidu.fis.velocity.directive.Extends
</prop>
<!--<prop key="file.resource.loader.class">org.apache.velocity.tools.view.servlet.WebappLoader</prop>-->
<!--<prop key="file.resource.loader.cache">false</prop>-->
<!--<prop key="file.resource.loader.modificationCheckInterval">1</prop>-->
<prop key="velocimacro.library">macro.vm</prop>
</props>
</property>
</bean>
<bean class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
<property name="order" value="1"/>
<property name="cache" value="true"/>
<property name="prefix" value=""/>
<property name="suffix" value=".vm"/>
<property name="cacheUnresolved" value="false"/>
<property name="exposeSpringMacroHelpers" value="true"/>
<property name="contentType" value="text/html;charset=UTF-8"/>
<property name="attributesMap">
<map>
<entry key="esc">
<bean class="org.apache.velocity.tools.generic.EscapeTool"/>
</entry>
<entry key="render">
<bean class="org.apache.velocity.tools.generic.RenderTool"/>
</entry>
<entry key="link">
<bean class="org.apache.velocity.tools.generic.LinkTool"/>
</entry>
<!--其他你觉得有用的 velocity tools-->
</map>
</property>
</bean>
发布后
#extends("page/layout/front.vm")
Settings.DEFAULT_PATH不能自定义,当然幸好不是final的
顺便吐槽一下日志都是sysout的.......以及各种写死的WEB-INF
mvn install:install-file -Dfile=./target/fis-velocity-tools-1.8.jar -DgroupId=com.baidu.fis -DartifactId=fis-velocity-tools -Dversion=1.8 -Dpackaging=jar
设置 fis.properties 也没用。
但是改成后面的绝对路径就可以读到了。
没有 spring-boot 的 demo 可以看看?
J2EE应用部署后,有一个context,一般我们可以通过$request.getContextPath来获取绝对路径,然后拼接上静态资源例如,例如 <script src="$request.contextPath/static/js/require.js"></script>
由于#requrie是根据map.json表来映射的,而且我也不可以在fis-conf.js中把url写死,有什么更好的解决方法?
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Sep 09 13:52:07 CST 2015
There was an unexpected error (type=Internal Server Error, status=500).
Unable to find resource 'page/page/layout/front.vm'
看了一下源码结构 不理解 WEB-INF/views/index.vm 是在什么情况下被渲染出来?
RewriteFilter读取的是写死的server.conf,而最新版的jello,release已经把server.conf产出为server[moduel_name].conf,比如home模块则是 serverhome.conf。这样可以使多个模块的conf文件不至于相互覆盖。
望更新。谢谢。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.