Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/386.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在SpringWebFlow中访问HttpServletRequest对象_Java_Spring Webflow - Fatal编程技术网

Java 在SpringWebFlow中访问HttpServletRequest对象

Java 在SpringWebFlow中访问HttpServletRequest对象,java,spring-webflow,Java,Spring Webflow,我正在使用WebFlow,希望将当前区域设置添加到流中。 我已经有一个resolveLocale方法使用此签名执行此操作: public Locale resolveLocale (HttpServletRequest request); 我想在我的WebFlow XML中添加如下内容: <on-start> <evaluate expression="localeService.resolveLocale(???)" result="flowScope.locale"/&g

我正在使用WebFlow,希望将当前区域设置添加到流中。 我已经有一个resolveLocale方法使用此签名执行此操作:

public Locale resolveLocale (HttpServletRequest request);
我想在我的WebFlow XML中添加如下内容:

<on-start>
<evaluate expression="localeService.resolveLocale(???)" result="flowScope.locale"/>
</on-start>

现在,我不知道该把什么放进去???参数部分

有什么想法吗?感谢阅读。

我没有使用Web流,但是假设它与Spring的其余部分类似,您可以使用RequestContextHolder来实现这一点。快速的谷歌搜索表明,WebFlow甚至可以为您提供一个-甚至更好的

您可以使用这种方式获得HttpServletRequest

(HttpServletRequest)RequestContextHolder.getRequestContext().getExternalContext().getNativeRequest()

谢谢你的提示。我在我的服务中使用以下行(我的SWF配置使用SessionLocalerResolver):


访问区域设置的一种更简单的方法是spring的LocaleContextHolder

只需调用:LocaleContextHolder.getLocale()

Locale locale = (Locale) RequestContextHolder.getRequestAttributes().getAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME, RequestAttributes.SCOPE_SESSION);