Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
后端镜像
java镜像
Smart Framework
提交
7a6292e3
S
Smart Framework
项目概览
后端镜像
/
java镜像
/
Smart Framework
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Smart Framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7a6292e3
编写于
2月 11, 2014
作者:
黄
黄勇
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【I】合并 smart-framework 1.0.1 的代码
上级
9133ab6f
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
17 addition
and
21 deletion
+17
-21
README.md
README.md
+3
-3
src/main/java/com/smart/framework/ContainerListener.java
src/main/java/com/smart/framework/ContainerListener.java
+1
-2
src/main/java/com/smart/framework/EncodingFilter.java
src/main/java/com/smart/framework/EncodingFilter.java
+1
-1
src/main/java/com/smart/framework/FrameworkConstant.java
src/main/java/com/smart/framework/FrameworkConstant.java
+1
-3
src/main/java/com/smart/framework/helper/UploadHelper.java
src/main/java/com/smart/framework/helper/UploadHelper.java
+2
-1
src/main/java/com/smart/framework/util/CodecUtil.java
src/main/java/com/smart/framework/util/CodecUtil.java
+4
-4
src/main/java/com/smart/framework/util/FileUtil.java
src/main/java/com/smart/framework/util/FileUtil.java
+1
-1
src/main/java/com/smart/framework/util/WebUtil.java
src/main/java/com/smart/framework/util/WebUtil.java
+4
-6
未找到文件。
README.md
浏览文件 @
7a6292e3
...
...
@@ -3,11 +3,11 @@ Smart Framework
源码地址:
http://git.oschina.net/huangyong/smart-framework
应用示例:
http://git.oschina.net/huangyong/smart-sample
项目聚合:
http://git.oschina.net/huangyong/smart-parent
应用示例:
http://git.oschina.net/huangyong/smart-sample
系列博文:
http://my.oschina.net/huangyong/blog/158380
\ No newline at end of file
src/main/java/com/smart/framework/ContainerListener.java
浏览文件 @
7a6292e3
...
...
@@ -18,11 +18,10 @@ public class ContainerListener implements ServletContextListener {
@Override
public
void
contextInitialized
(
ServletContextEvent
sce
)
{
ServletContext
context
=
sce
.
getServletContext
();
// 初始化相关 Helper 类
HelperLoader
.
init
();
// 添加 Servlet 映射
addServletMapping
(
context
);
addServletMapping
(
sce
.
getServletContext
()
);
}
@Override
...
...
src/main/java/com/smart/framework/EncodingFilter.java
浏览文件 @
7a6292e3
...
...
@@ -18,7 +18,7 @@ public class EncodingFilter implements Filter {
@Override
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
chain
)
throws
IOException
,
ServletException
{
request
.
setCharacterEncoding
(
FrameworkConstant
.
CHARSET_UTF
);
request
.
setCharacterEncoding
(
FrameworkConstant
.
UTF_8
);
chain
.
doFilter
(
request
,
response
);
}
...
...
src/main/java/com/smart/framework/FrameworkConstant.java
浏览文件 @
7a6292e3
...
...
@@ -2,8 +2,7 @@ package com.smart.framework;
public
interface
FrameworkConstant
{
String
CHARSET_UTF
=
"UTF-8"
;
String
CHARSET_ISO
=
"ISO-8859-1"
;
String
UTF_8
=
"UTF-8"
;
String
APP_HOME_PAGE
=
"app.home_page"
;
String
APP_JSP_PATH
=
"app.jsp_path"
;
...
...
@@ -15,5 +14,4 @@ public interface FrameworkConstant {
String
JSP_SERVLET_NAME
=
"jsp"
;
String
PLUGIN_PACKAGE
=
"com.smart.plugin"
;
String
MODULE_PACKAGE
=
"com.smart.module"
;
}
src/main/java/com/smart/framework/helper/UploadHelper.java
浏览文件 @
7a6292e3
...
...
@@ -75,7 +75,7 @@ public class UploadHelper {
String
fieldName
=
fileItem
.
getFieldName
();
if
(
fileItem
.
isFormField
())
{
// 处理普通字段
String
fieldValue
=
fileItem
.
getString
(
FrameworkConstant
.
CHARSET_UTF
);
String
fieldValue
=
fileItem
.
getString
(
FrameworkConstant
.
UTF_8
);
fieldMap
.
put
(
fieldName
,
fieldValue
);
}
else
{
// 处理文件字段
...
...
@@ -92,6 +92,7 @@ public class UploadHelper {
}
// 初始化参数列表
paramList
.
add
(
fieldMap
);
// 不管一个文件还是多个文件,都映射为 Multiparts 参数
if
(
CollectionUtil
.
isNotEmpty
(
multipartList
))
{
paramList
.
add
(
new
Multiparts
(
multipartList
));
}
else
{
...
...
src/main/java/com/smart/framework/util/CodecUtil.java
浏览文件 @
7a6292e3
...
...
@@ -19,7 +19,7 @@ public class CodecUtil {
public
static
String
urlEncode
(
String
str
)
{
String
target
;
try
{
target
=
URLEncoder
.
encode
(
str
,
FrameworkConstant
.
CHARSET_UTF
);
target
=
URLEncoder
.
encode
(
str
,
FrameworkConstant
.
UTF_8
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"编码出错!"
,
e
);
throw
new
RuntimeException
(
e
);
...
...
@@ -31,7 +31,7 @@ public class CodecUtil {
public
static
String
urlDecode
(
String
str
)
{
String
target
;
try
{
target
=
URLDecoder
.
decode
(
str
,
FrameworkConstant
.
CHARSET_UTF
);
target
=
URLDecoder
.
decode
(
str
,
FrameworkConstant
.
UTF_8
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"解码出错!"
,
e
);
throw
new
RuntimeException
(
e
);
...
...
@@ -43,7 +43,7 @@ public class CodecUtil {
public
static
String
encodeBase64
(
String
str
)
{
String
target
;
try
{
target
=
Base64
.
encodeBase64URLSafeString
(
str
.
getBytes
(
FrameworkConstant
.
CHARSET_UTF
));
target
=
Base64
.
encodeBase64URLSafeString
(
str
.
getBytes
(
FrameworkConstant
.
UTF_8
));
}
catch
(
UnsupportedEncodingException
e
)
{
logger
.
error
(
"编码出错!"
,
e
);
throw
new
RuntimeException
(
e
);
...
...
@@ -55,7 +55,7 @@ public class CodecUtil {
public
static
String
decodeBase64
(
String
str
)
{
String
target
;
try
{
target
=
new
String
(
Base64
.
decodeBase64
(
str
),
FrameworkConstant
.
CHARSET_UTF
);
target
=
new
String
(
Base64
.
decodeBase64
(
str
),
FrameworkConstant
.
UTF_8
);
}
catch
(
UnsupportedEncodingException
e
)
{
logger
.
error
(
"解码出错!"
,
e
);
throw
new
RuntimeException
(
e
);
...
...
src/main/java/com/smart/framework/util/FileUtil.java
浏览文件 @
7a6292e3
...
...
@@ -120,7 +120,7 @@ public class FileUtil {
try
{
FileUtil
.
createFile
(
filePath
);
os
=
new
BufferedOutputStream
(
new
FileOutputStream
(
filePath
));
w
=
new
OutputStreamWriter
(
os
,
FrameworkConstant
.
CHARSET_UTF
);
w
=
new
OutputStreamWriter
(
os
,
FrameworkConstant
.
UTF_8
);
w
.
write
(
fileContent
);
w
.
flush
();
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/smart/framework/util/WebUtil.java
浏览文件 @
7a6292e3
package
com.smart.framework.util
;
import
com.smart.framework.FrameworkConstant
;
import
java.awt.Color
;
import
java.awt.Font
;
import
java.awt.Graphics2D
;
import
java.awt.*
;
import
java.awt.image.BufferedImage
;
import
java.io.BufferedInputStream
;
import
java.io.BufferedOutputStream
;
...
...
@@ -33,7 +31,7 @@ public class WebUtil {
try
{
// 设置响应头
response
.
setContentType
(
"application/json"
);
// 指定内容类型为 JSON 格式
response
.
setCharacterEncoding
(
FrameworkConstant
.
CHARSET_UTF
);
// 防止中文乱码
response
.
setCharacterEncoding
(
FrameworkConstant
.
UTF_8
);
// 防止中文乱码
// 向响应中写入数据
PrintWriter
writer
=
response
.
getWriter
();
...
...
@@ -49,7 +47,7 @@ public class WebUtil {
try
{
// 设置响应头
response
.
setContentType
(
"text/html"
);
// 指定内容类型为 HTML 格式
response
.
setCharacterEncoding
(
FrameworkConstant
.
CHARSET_UTF
);
// 防止中文乱码
response
.
setCharacterEncoding
(
FrameworkConstant
.
UTF_8
);
// 防止中文乱码
// 向响应中写入数据
PrintWriter
writer
=
response
.
getWriter
();
...
...
@@ -182,7 +180,7 @@ public class WebUtil {
public
static
void
downloadFile
(
HttpServletResponse
response
,
String
filePath
)
{
try
{
String
originalFileName
=
FilenameUtils
.
getName
(
filePath
);
String
downloadedFileName
=
new
String
(
originalFileName
.
getBytes
(
"GBK"
),
FrameworkConstant
.
CHARSET_ISO
);
String
downloadedFileName
=
new
String
(
originalFileName
.
getBytes
(
"GBK"
),
"ISO8859_1"
);
// 防止中文乱码
response
.
setContentType
(
"application/octet-stream"
);
response
.
addHeader
(
"Content-Disposition"
,
"attachment;filename=\""
+
downloadedFileName
+
"\""
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录