Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
52cca48f
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
52cca48f
编写于
10月 04, 2013
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
8b3afda6
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
50 addition
and
48 deletion
+50
-48
spring-context/src/main/java/org/springframework/format/datetime/DateFormatter.java
...va/org/springframework/format/datetime/DateFormatter.java
+14
-12
spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/HsqlTableMetaDataProvider.java
...amework/jdbc/core/metadata/HsqlTableMetaDataProvider.java
+4
-5
spring-web/src/main/java/org/springframework/web/util/CookieGenerator.java
...in/java/org/springframework/web/util/CookieGenerator.java
+6
-2
spring-web/src/main/java/org/springframework/web/util/WebUtils.java
.../src/main/java/org/springframework/web/util/WebUtils.java
+0
-2
spring-webmvc/src/main/java/org/springframework/web/servlet/LocaleResolver.java
.../java/org/springframework/web/servlet/LocaleResolver.java
+8
-9
spring-webmvc/src/main/java/org/springframework/web/servlet/ThemeResolver.java
...n/java/org/springframework/web/servlet/ThemeResolver.java
+18
-18
未找到文件。
spring-context/src/main/java/org/springframework/format/datetime/DateFormatter.java
浏览文件 @
52cca48f
...
...
@@ -29,7 +29,6 @@ import java.util.TimeZone;
import
org.springframework.format.Formatter
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.springframework.format.annotation.DateTimeFormat.ISO
;
import
org.springframework.util.Assert
;
import
org.springframework.util.StringUtils
;
/**
...
...
@@ -45,6 +44,7 @@ import org.springframework.util.StringUtils;
public
class
DateFormatter
implements
Formatter
<
Date
>
{
private
static
final
Map
<
ISO
,
String
>
ISO_PATTERNS
;
static
{
Map
<
ISO
,
String
>
formats
=
new
HashMap
<
DateTimeFormat
.
ISO
,
String
>(
4
);
formats
.
put
(
ISO
.
DATE
,
"yyyy-MM-dd"
);
...
...
@@ -170,34 +170,36 @@ public class DateFormatter implements Formatter<Date> {
if
(
StringUtils
.
hasLength
(
this
.
pattern
))
{
return
new
SimpleDateFormat
(
this
.
pattern
,
locale
);
}
if
(
iso
!=
null
&&
iso
!=
ISO
.
NONE
)
{
String
pattern
=
ISO_PATTERNS
.
get
(
iso
);
Assert
.
state
(
pattern
!=
null
,
"Unsupported ISO format "
+
iso
);
if
(
this
.
iso
!=
null
&&
this
.
iso
!=
ISO
.
NONE
)
{
String
pattern
=
ISO_PATTERNS
.
get
(
this
.
iso
);
if
(
pattern
==
null
)
{
throw
new
IllegalStateException
(
"Unsupported ISO format "
+
this
.
iso
);
}
SimpleDateFormat
format
=
new
SimpleDateFormat
(
pattern
);
format
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"UTC"
));
return
format
;
}
if
(
StringUtils
.
hasLength
(
stylePattern
))
{
if
(
StringUtils
.
hasLength
(
this
.
stylePattern
))
{
int
dateStyle
=
getStylePatternForChar
(
0
);
int
timeStyle
=
getStylePatternForChar
(
1
);
if
(
dateStyle
!=
-
1
&&
timeStyle
!=
-
1
)
{
if
(
dateStyle
!=
-
1
&&
timeStyle
!=
-
1
)
{
return
DateFormat
.
getDateTimeInstance
(
dateStyle
,
timeStyle
,
locale
);
}
if
(
dateStyle
!=
-
1
)
{
if
(
dateStyle
!=
-
1
)
{
return
DateFormat
.
getDateInstance
(
dateStyle
,
locale
);
}
if
(
timeStyle
!=
-
1
)
{
if
(
timeStyle
!=
-
1
)
{
return
DateFormat
.
getTimeInstance
(
timeStyle
,
locale
);
}
throw
new
IllegalStateException
(
"Unsupported style pattern '"
+
stylePattern
+
"'"
);
throw
new
IllegalStateException
(
"Unsupported style pattern '"
+
this
.
stylePattern
+
"'"
);
}
return
DateFormat
.
getDateInstance
(
this
.
style
,
locale
);
}
private
int
getStylePatternForChar
(
int
index
)
{
if
(
stylePattern
!=
null
&&
stylePattern
.
length
()
>
index
)
{
switch
(
stylePattern
.
charAt
(
index
))
{
if
(
this
.
stylePattern
!=
null
&&
this
.
stylePattern
.
length
()
>
index
)
{
switch
(
this
.
stylePattern
.
charAt
(
index
))
{
case
'S'
:
return
DateFormat
.
SHORT
;
case
'M'
:
return
DateFormat
.
MEDIUM
;
case
'L'
:
return
DateFormat
.
LONG
;
...
...
@@ -205,7 +207,7 @@ public class DateFormatter implements Formatter<Date> {
case
'-'
:
return
-
1
;
}
}
throw
new
IllegalStateException
(
"Unsupported style pattern '"
+
stylePattern
+
"'"
);
throw
new
IllegalStateException
(
"Unsupported style pattern '"
+
this
.
stylePattern
+
"'"
);
}
}
spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/HsqlTableMetaDataProvider.java
浏览文件 @
52cca48f
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
3
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -20,8 +20,8 @@ import java.sql.DatabaseMetaData;
import
java.sql.SQLException
;
/**
* The HSQL specific implementation of the {@link TableMetaDataProvider}.
Suports a feature for
* retreiving generated keys without the JDBC 3.0 getGeneratedKeys support.
* The HSQL specific implementation of the {@link TableMetaDataProvider}.
*
Supports a feature for
retreiving generated keys without the JDBC 3.0 getGeneratedKeys support.
*
* @author Thomas Risberg
* @since 2.5
...
...
@@ -32,15 +32,14 @@ public class HsqlTableMetaDataProvider extends GenericTableMetaDataProvider {
super
(
databaseMetaData
);
}
@Override
public
boolean
isGetGeneratedKeysSimulated
()
{
return
true
;
}
@Override
public
String
getSimpleQueryForGetGeneratedKey
(
String
tableName
,
String
keyColumnName
)
{
return
"select max(identity()) from "
+
tableName
;
}
}
spring-web/src/main/java/org/springframework/web/util/CookieGenerator.java
浏览文件 @
52cca48f
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
3
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -22,13 +22,15 @@ import javax.servlet.http.HttpServletResponse;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.util.Assert
;
/**
* Helper class for cookie generation, carrying cookie descriptor settings
* as bean properties and being able to add and remove cookie to/from a
* given response.
*
* <p>Can serve as base class for components that generate specific cookies,
*
like CookieLocaleResolc
er and CookieThemeResolver.
*
such as CookieLocaleResolv
er and CookieThemeResolver.
*
* @author Juergen Hoeller
* @since 1.1.4
...
...
@@ -177,6 +179,7 @@ public class CookieGenerator {
* @see #setCookieMaxAge
*/
public
void
addCookie
(
HttpServletResponse
response
,
String
cookieValue
)
{
Assert
.
notNull
(
response
,
"HttpServletResponse must not be null"
);
Cookie
cookie
=
createCookie
(
cookieValue
);
Integer
maxAge
=
getCookieMaxAge
();
if
(
maxAge
!=
null
)
{
...
...
@@ -204,6 +207,7 @@ public class CookieGenerator {
* @see #setCookiePath
*/
public
void
removeCookie
(
HttpServletResponse
response
)
{
Assert
.
notNull
(
response
,
"HttpServletResponse must not be null"
);
Cookie
cookie
=
createCookie
(
""
);
cookie
.
setMaxAge
(
0
);
response
.
addCookie
(
cookie
);
...
...
spring-web/src/main/java/org/springframework/web/util/WebUtils.java
浏览文件 @
52cca48f
...
...
@@ -22,7 +22,6 @@ import java.util.Enumeration;
import
java.util.Map
;
import
java.util.StringTokenizer
;
import
java.util.TreeMap
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.ServletRequestWrapper
;
...
...
@@ -199,7 +198,6 @@ public abstract class WebUtils {
if
(
servletContext
==
null
)
{
return
null
;
}
Assert
.
notNull
(
servletContext
,
"ServletContext must not be null"
);
String
param
=
servletContext
.
getInitParameter
(
HTML_ESCAPE_CONTEXT_PARAM
);
return
(
StringUtils
.
hasText
(
param
)?
Boolean
.
valueOf
(
param
)
:
null
);
}
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/LocaleResolver.java
浏览文件 @
52cca48f
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
3
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -17,7 +17,6 @@
package
org.springframework.web.servlet
;
import
java.util.Locale
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -27,22 +26,22 @@ import javax.servlet.http.HttpServletResponse;
* request and response.
*
* <p>This interface allows for implementations based on request, session,
* cookies, etc. The default implementation is AcceptHeaderLocaleResolver,
* cookies, etc. The default implementation is
* {@link org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver},
* simply using the request's locale provided by the respective HTTP header.
*
* <p>Use {@code RequestContext.getLocale()} to retrieve the current locale
* in controllers or views, independent of the actual resolution strategy.
* <p>Use {@link org.springframework.web.servlet.support.RequestContext#getLocale()}
* to retrieve the current locale in controllers or views, independent
* of the actual resolution strategy.
*
* @author Juergen Hoeller
* @since 27.02.2003
* @see org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver
* @see org.springframework.web.servlet.support.RequestContext#getLocale
*/
public
interface
LocaleResolver
{
/**
* Resolve the current locale via the given request.
*
Should
return a default locale as fallback in any case.
*
Can
return a default locale as fallback in any case.
* @param request the request to resolve the locale for
* @return the current locale (never {@code null})
*/
...
...
@@ -54,7 +53,7 @@ public interface LocaleResolver {
* @param response the response to be used for locale modification
* @param locale the new locale, or {@code null} to clear the locale
* @throws UnsupportedOperationException if the LocaleResolver implementation
* does not support dynamic changing of the
them
e
* does not support dynamic changing of the
local
e
*/
void
setLocale
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Locale
locale
);
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/ThemeResolver.java
浏览文件 @
52cca48f
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
3
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -25,7 +25,8 @@ import javax.servlet.http.HttpServletResponse;
* request and response.
*
* <p>This interface allows for implementations based on session,
* cookies, etc. The default implementation is FixedThemeResolver,
* cookies, etc. The default implementation is
* {@link org.springframework.web.servlet.theme.FixedThemeResolver},
* simply using a configured default theme.
*
* <p>Note that this resolver is only responsible for determining the
...
...
@@ -33,35 +34,34 @@ import javax.servlet.http.HttpServletResponse;
* gets looked up by DispatcherServlet via the respective ThemeSource,
* i.e. the current WebApplicationContext.
*
* <p>Use RequestContext.getTheme() to retrieve the current theme in
* controllers or views, independent of the actual resolution strategy.
* <p>Use {@link org.springframework.web.servlet.support.RequestContext#getTheme()}
* to retrieve the current theme in controllers or views, independent
* of the actual resolution strategy.
*
* @author Jean-Pierre Pawlak
* @author Juergen Hoeller
* @since 17.06.2003
* @see org.springframework.web.servlet.theme.FixedThemeResolver
* @see org.springframework.ui.context.Theme
* @see org.springframework.ui.context.ThemeSource
* @see org.springframework.web.servlet.support.RequestContext#getTheme
*/
public
interface
ThemeResolver
{
/**
* Resolve the current theme name via the given request.
* Should return a default theme as fallback in any case.
* @param request request to be used for resolution
* @return the current theme name
*/
/**
* Resolve the current theme name via the given request.
* Should return a default theme as fallback in any case.
* @param request request to be used for resolution
* @return the current theme name
*/
String
resolveThemeName
(
HttpServletRequest
request
);
/**
* Set the current theme name to the given one.
* @param request request to be used for theme name modification
* @param response response to be used for theme name modification
* @param themeName the new theme name
/**
* Set the current theme name to the given one.
* @param request request to be used for theme name modification
* @param response response to be used for theme name modification
* @param themeName the new theme name
* @throws UnsupportedOperationException if the ThemeResolver implementation
* does not support dynamic changing of the theme
*/
*/
void
setThemeName
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
themeName
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录