例如:
Object o1 = new ArrayList<String>();
Object o2 = new ArrayList<String>(){};
Object o3 = new ArrayList<String>(){{}};
Run Code Online (Sandbox Code Playgroud)
有什么不同?
我不能谷歌java的第2 /第3语法,任何参考?
在asp.net中,我使用此配置部分拒绝所有页面的匿名用户.
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
Run Code Online (Sandbox Code Playgroud)
我使用以下内容来声明匿名可以访问的异常.
<location path="Welcome.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
Run Code Online (Sandbox Code Playgroud)
这对我来说很好.
但是,如何才能将默认页面设置为例外?(例如:匿名者只能访问http:// mysite /,但不能访问网站中的任何其他页面?)
我尝试使用location path ="〜/"或"/",但它不起作用.
我有一个像这样的控制器:
@Controller
public class HomeController {
@RequestMapping(value = "/update", method = RequestMethod.POST)
public String update(@RequestParam("user") User user, ModelMap model){
SaveUserToDatabase(user);
return "index";
}
@ModelAttribute("user")
String getUser() {
return LoadCurrentUserFromDataBase();
}
}
Run Code Online (Sandbox Code Playgroud)
简而言之,我的观点user几乎可以在每个动作中呈现HomeController,但我不想编码:
model.addAttribute("user", LoadCurrentUserFromDataBase())
Run Code Online (Sandbox Code Playgroud)
在每一个行动中,相反,我正在寻找一种方式@ModelAttribute来揭露user我的所有观点.
但是,根据文档,@ModelAttribute控制器中的方法在 @RequestMapping方法之前,在同一个控制器中调用.
至于我的代码,getUser之前被调用update,但我想获得更新的用户.
有没有办法在动作之后公开user属性而不在每个动作中显式调用?model.addAttribute
一个非常简单和天真的问题:为什么这是真的?
new RegExp('^[a-z]+$', 'i').test('B')
Run Code Online (Sandbox Code Playgroud)
显然'B'是[az]的?
当我写日志到Windows事件日志时:
System.Diagnostics.EventLog.WriteEntry("SourceName", a_long_string);
Run Code Online (Sandbox Code Playgroud)
我得到以下例外:
日志条目字符串太长.写入事件日志的字符串不能超过32766个字符.
然后我将我的日志消息拆分为2个或更多字符串.但我认为这不是一个好主意.任何变通方法?(例如extern每个日志条目的限制)
asp.net ×2
java ×2
arraylist ×1
c# ×1
event-log ×1
javascript ×1
membership ×1
regex ×1
spring ×1
spring-mvc ×1