假设我有一个桌面应用程序,可以充当一堆汽车的车库:
@Entity
public class Garage {
private List<Car> cars = new ArrayList<Car>();
...
}
Run Code Online (Sandbox Code Playgroud)
桌面应用程序有一个"模拟"按钮,可以启动一个新线程并开始调用Garage,Car,Wheel等方法.此模拟可能需要长达10分钟才能运行.目前我有一个看起来像这样的课程:
beginTransaction();
Garage garage = garageDao.findGarage(1);
List<Car> cars = garage.getCars();
for (Car car : cars) {
// call methods on the car to lazily fetch other things like wheels...
}
commitTransaction();
Run Code Online (Sandbox Code Playgroud)
此代码只执行"读取"而从不"写入"
因此,上述情况可能需要很长时间,具体取决于汽车需要多少服务.在发生上述情况时,用户可以继续使用桌面应用程序.他们可能会选择更改上述交易中使用的汽车颜色.
我的问题是,上述长期交易是否会阻止汽车颜色的变化?即,用户在桌面应用程序中更改汽车的颜色将被阻止提交更改,直到长事务完成?
我正在使用本指南:http://edgeguides.rubyonrails.org/i18n.html
我想要的是什么:
/about去pages#about用的拖欠区域en.
/en/about转到pages#about的语言环境en.
/es/about转到pages#about的语言环境es.
我得到了什么:
/about转到root_path的语言环境about.
/en/about转到pages#about的语言环境en.
/es/about转到pages#about的语言环境es.
这是一些代码:
# config/routes.rb
match '/:locale' => 'pages#news'
scope "(:locale)", :locale => /en|es/ do
match '/abcd' => 'pages#abcd'
match '/plan' => 'pages#plan'
match '/about' => 'pages#about'
match '/history' => 'pages#history'
match '/projects' => 'pages#projects'
match '/donate' => 'pages#donate'
match …Run Code Online (Sandbox Code Playgroud) 我有一个控制器有很多动作,它指定一个默认的类级别@PreAuthorize注释,但我想让任何人进入的一个动作("显示"动作).
@RequestMapping("/show/{pressReleaseId}")
@PreAuthorize("permitAll")
public ModelAndView show(@PathVariable long pressReleaseId) {
ModelAndView modelAndView = new ModelAndView(view("show"));
modelAndView.addObject("pressRelease",
sysAdminService.findPressRelease(pressReleaseId));
return modelAndView;
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,Spring Security抛出了这个异常:
org.springframework.security.authentication.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext
at org.springframework.security.access.intercept.AbstractSecurityInterceptor.credentialsNotFound(AbstractSecurityInterceptor.java:321)
at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:195)
at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:64)
Run Code Online (Sandbox Code Playgroud)
如何让Spring Security不抛出此异常?我只是想让任何人进入 - 非经过身份验证的用户和经过身份验证的用户 - 每个人.
我唯一的解决方案就是将这个方法完全放在另一个控制器中,而根本没有@PreAuthorize ......这将起作用,但那是愚蠢的.我想在同一个控制器中保留我的所有新闻稿动作.
谢谢您的帮助!
authentication authorization controller exception spring-security
我对Stack vs Heap之间的内存分配基础感到困惑.根据标准定义(每个人都说的东西),所有值类型都将被分配到堆栈,参考类型将进入堆.
现在考虑以下示例:
class MyClass
{
int myInt = 0;
string myString = "Something";
}
class Program
{
static void Main(string[] args)
{
MyClass m = new MyClass();
}
}
Run Code Online (Sandbox Code Playgroud)
现在,内存分配将如何在c#中发生?MyClass(即m)的对象是否会完全分配给堆?也就是说,int myInt和string myString既会去堆?
或者,该对象将分为两部分,并将分配给两个内存位置,即堆栈和堆?
有没有办法将fd"转换"为FILE*或者是否有mkstemp版本返回FILE*?
任何人都知道任何文档可能在哪里?到目前为止我只发现了这个
http://code.google.com/appengine/articles/djangoforms.html
EmailProperty()仅验证空字符串... 叹息
def method
a = 3
b = 4
some_method_that_gives # [a, b]
end
Run Code Online (Sandbox Code Playgroud) 我试图用来grep匹配包含两个不同字符串的行.我尝试了以下但是这匹配包含string1 或 string2的行,这不是我想要的.
grep 'string1\|string2' filename
Run Code Online (Sandbox Code Playgroud)
那么我如何grep只匹配包含两个字符串的行?