您好我正在尝试在我的Spring MVC Web应用程序中配置消息源.
我目前使用ReloadableResourceBundleMessageSource运行它,但我无法使用ResourceBundleMessageSource运行它.我宁愿使用ResourceBundleMessageSource,因为我不需要Reload功能,而ResourceBundleMessageSource的效率稍高.
在我的rootApplicationContext中,我已经定义了bean如下.
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="/resources/locale/messages" />
<property name="defaultEncoding" value="UTF-8"/>
</bean>
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.SessionLocaleResolver" />
<bean id="handlerMapping"
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="interceptors">
<ref bean="localeChangeInterceptor" />
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
这工作很精细..
但是一改变到
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="/resources/locale/messages" />
<property name="defaultEncoding" value="UTF-8"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
该应用程序打破了例外:
12:35:57,433 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/ SpringJAXWS].[jsp]](http-localhost-127.0.0.1-8080-1 Servlet jsp的Servlet.service()抛出异常:org.apache.tiles.util.TilesIOException:JSPException包括路径'/jsp/views/layout/top.jsp'.at org.apache.tiles.servlet.context.ServletUtil.wrapServletException(ServletUtil.java:241)[tiles-servlet-2.2.2.jar:2.2.2] at org.apache.tiles.jsp.context.JspTilesRequestContext.include (JspTilesRequestContext.java:105)[tiles-jsp-2.2.2.jar:2.2.2]
救命 !
https://github.com/localghost8080/JaxWS
https://github.com/localghost8080/JaxWS/blob/master/ResourceBundleException.txt
我正在尝试Drools规则引擎,我是一个初学者.
我在单个规则文件中有以下规则:
rule "A stand alone rule"
salience 2
no-loop
when
$account : Account()
Account($account.balance>100)
then
System.out.println("balance>100");
System.out.println($account.getBalance());
System.out.println($account.getCustomer().getName());
end
rule "A second Rule"
salience 1
no-loop
when
$account : Account()
Account($account.balance<100)
then
System.out.println("balance<100");
System.out.println($account.getBalance());
System.out.println($account.getCustomer().getName());
end
Run Code Online (Sandbox Code Playgroud)
在StatefulKnowledgeSession中,我通过了两个账户,一个账户余额为15000,另一个账户余额为15,
Account account=new Account(7l,15000l);
Account account1=new Account(5l,15l);
Customer customer = new Customer("Samrat", 28, "Sector51", account);
Customer customer1 = new Customer("Alexi", 28, "Sector50", account1);
account.setCustomer(customer);
account1.setCustomer(customer1);
session.insert(account);
session.insert(account1);
session.fireAllRules();
Run Code Online (Sandbox Code Playgroud)
根据我的预期结果应该是每个规则应该只被触发一次,并且应该打印相应的对象.
但我得到的结果是:
balance>100
15000
Samrat
balance>100
15000
Samrat
balance<100
15
Alexi
balance<100
15
Alexi
Run Code Online (Sandbox Code Playgroud)
我无法理解为什么每条规则都运行两次????