2013年7月27日星期六

spring MVC controller mappings for each execution are mutually exclusive do ?

spring MVC controller mappings for each execution are mutually exclusive do ?

If a request is mapped in the following code:
fileName = ... + new Date (). getTime () + ...;

handle multiple requests at the same time , the implementation of this code are not mutually exclusive ?
contact with spring time is not long , experts explain
------ Solution --------------------------- -----------------
fileName if it is a local variable , and certainly no problem ; property if it is , then see how many you this Controller entry , multiple entry between the existence of re-entry problems .
------ Solution ---------------------------------------- ----
do not recommend using this approach to achieve the unique file name ,
Although spring is a single case of default mode , but you code should appear within a method body ,
So although the spring container controller is a single case , but it always generates a new Date object ,
concern is possible at the same time multiple concurrent access , resulting filename is not unique.
------ For reference only -------------------------------------- -
fileName attention to thread safety issues
------ For reference only ---------------------------- -----------
plus other unique identifier to reach the letter .

1 条评论:

  1. Thank you, my boss assigned me such a task and i could do it fast.Thank u very much

    回复删除