有人可以解释一下Spring bean中的范围,我总是只使用'原型',但是我可以用其他参数代替吗?
我正在谈论的例子
<bean id="customerInfoController" class="com.action.Controller" scope="prototype">
<property name="accountDao" ref="accountDao"/>
<property name="utilityDao" ref="utilityDao"/>
<property name="account_usageDao" ref="account_usageDao"/>
</bean>
Run Code Online (Sandbox Code Playgroud) 假设我有一个 try 语句和空 catch 是不好的做法吗?例如,说我有 2 次单独的尝试,其中一个可能失败但另一个成功或两者都成功或任何可能的组合。处理这样的代码是不好的做法吗?
例子
if( mode == Modes.EDIT ){
try {user = userBo.findById(id).get(0); }
catch(Exception e) { }
try{
result = this.initializeEntityById(accountDao, id);
if( !result.equals(SUCCESS) ){
return result;
}
}
catch(Exception e){ }
}
Run Code Online (Sandbox Code Playgroud)
在这个例子中,关注的变量是“id”,我不确定传入的值是否有效,在前端它并不重要,因为代码处理传入的任何内容并提供正确的显示。
所以问题真的是: