我使用的解决方案:
将 filter-config-v1-spring.xml 中的以下部分添加到 defaultCommerceWebServicesFilterChainListV1
<!-- Custom filter to enable Fallback mechanism -->
<ref bean="languageFallbackFilter"/>
同样在列表之后添加 bean 定义
<bean id="languageFallbackFilter" class="b2b.hybris.commercewebservices.filter.LanguageFallbackFilter">
<property name="i18nService" ref="i18nService" />
</bean>
当然还要创建类 LanguageFallbackFilter
package b2b.hybris.commercewebservices.filter;
import de.hybris.platform.servicelayer.i18n.I18NService;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.web.filter.OncePerRequestFilter;
/**
* This LanguageFallbackFilter will enable the Localization Fallback mechanism
*
*/
public class LanguageFallbackFilter extends OncePerRequestFilter
{
private static final Logger LOG = Logger.getLogger(LanguageFallbackFilter.class);
private I18NService i18nService;
@Override
protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response,
final FilterChain filterChain) throws ServletException, IOException
{
i18nService.setLocalizationFallbackEnabled(true);
filterChain.doFilter(request, response);
}
@Required
public void setI18nService(final I18NService i18nService)
{
this.i18nService = i18nService;
}
}