2013-01-24 53 views
0

我添加了textfield和速度脚本中的一个按钮,通过web应用程序使用。当web应用程序启动时,会读取start.properties文件。有一个属性:debug_on可以取两个值0或1.如何使用Java Script从属性文件读取值?

所以我想显示文本字段和按钮的debug_on值。如果我没有弄错(我不是JavaScript的专业人士),它可以通过javascript的速度脚本完成,但我需要获取属性值才能进一步移动。

我该如何实现它?

修订

速度脚本示例,其中主要的GWT(Java)的代码被嵌入在最后:

<!--doctype head declaration--> 

    <head> 
     <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
     <title>Web App</title> 
     <style> 
     <!-- styles --> 
     </style> 
     <link rel="stylesheet" href="/css/webapp.css" type="text/css"/> 
     <meta name='gwt:module' content='$uri'> 
    </head> 
    <body> 
     <script language="javascript" src="/$uri/com.myproject.gwt.main.nocache.js"></script> 
     <!-- TextField and button are located here --> 
     <table style="width: 300px; height: 100px;" class="gwt-DialogBox" cellpadding="0" cellspacing="5"> 
      <!-- some other part of a page tha will be persistent through all GWT pages --> 
     </table> 
    </body> 
    </html> 
+2

为什么这个标记为Java?问题是关于JavaScript不是吗? – Alderath

+0

@Alderath Velocity是一个Java模板引擎。 – Pointy

+0

@积分啊......好的。我的坏话! – Alderath

回答

0

速度在服务器上运行,JavaScript的运行在客户端上,将无法访问到任何服务器的文件。

可以使用Velocity设置JavaScript块中的值并使JS函数使用这些值。

<script type='text/javascript'> 
var startValue = '$debug.value'; 
</script> 
+0

嗯。我打算使用