从ini文件在jasp中的javascript中设置变量

从ini文件在jasp中的javascript中设置变量,javascript,spring-mvc,Javascript,Spring Mvc,在我的SpringMVC项目中,我有一个properties.property文件,其结构如下 TestOrderURL=blah LiveOrderURL=blah1 这些值在我的控制器中使用,并使用@Value注释读取 view[.jsp]有一个javascript函数,其中包含需要从上述属性文件中设置默认值的变量。有没有办法设定这个 My HomeController.java @RequestMapping(value = "/Home.html", method = RequestM

在我的SpringMVC项目中,我有一个properties.property文件,其结构如下

TestOrderURL=blah
LiveOrderURL=blah1
这些值在我的控制器中使用,并使用@Value注释读取

view[.jsp]有一个javascript函数,其中包含需要从上述属性文件中设置默认值的变量。有没有办法设定这个

My HomeController.java

@RequestMapping(value = "/Home.html", method = RequestMethod.GET)
public String home(Locale locale, Model model) 
{
    logger.info("Welcome home! the client locale is "+ locale.toString());
    return "Home";
}

将控制器中的变量设置为某个特定的作用域,以便可以通过或在javascript中访问它们

更新:

在控制器调用中:

request.getSession(false).setAttribute("YourProperty",propertyvalue);
然后在javascript中访问它们,如:

var property=<%=session.getAttribute("YourProperty")%>;

或者你也可以在你的
模型中设置

@Danglish Piyush:任何示例链接都将非常感谢您提供的信息。我更新了我的?为了在控制器中显示我的代码,没有HttpRequest类型的输入参数,我在发布之前尝试过,因为它返回抛出的异常[Request processing failed;嵌套的异常为java.lang.NullPointerException]model.AddAttributes不会抛出错误,但是我没有得到${YourProperty}的数据@我检查了代码,错误就在我这边。在EL中,我有一个;这导致了这个问题,而且js代码希望属性var是带引号的字符串。没有被填鸭式喂养的意图。但是非常感谢
@RequestMapping(value = "/Home.html", method = RequestMethod.GET)
public String home(Locale locale, Model model,HttpServletRequest request) 
{
    request.getSession(false).setAttribute("YourProperty",propertyvalue);
    logger.info("Welcome home! the client locale is "+ locale.toString());
    return "Home";
}