Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nouiWithSpringMVC
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gechengyang
nouiWithSpringMVC
Commits
2f926f92
Commit
2f926f92
authored
May 31, 2019
by
fukai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化下载
parent
679dbc65
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
42 deletions
+40
-42
AbstractCommonController.java
...resentation/noui/controller/AbstractCommonController.java
+35
-41
spring-mvc.xml
src/main/resources/spring-mvc.xml
+5
-1
No files found.
src/main/java/org/sss/presentation/noui/controller/AbstractCommonController.java
View file @
2f926f92
...
@@ -2,20 +2,14 @@ package org.sss.presentation.noui.controller;
...
@@ -2,20 +2,14 @@ package org.sss.presentation.noui.controller;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
log.Log
;
import
log.LogFactory
;
import
org.apache.commons.fileupload.FileItem
;
import
org.apache.commons.fileupload.disk.DiskFileItemFactory
;
import
org.apache.commons.fileupload.servlet.ServletFileUpload
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.sss.common.model.EventType
;
import
org.sss.common.model.EventType
;
import
org.sss.common.model.IBaseObject
;
import
org.sss.common.model.IBaseObject
;
import
org.sss.common.model.IDatafield
;
import
org.sss.common.model.IDatafield
;
...
@@ -37,7 +31,8 @@ import org.sss.presentation.noui.util.NoUiPresentationUtil;
...
@@ -37,7 +31,8 @@ import org.sss.presentation.noui.util.NoUiPresentationUtil;
import
org.sss.presentation.noui.util.RedisUtil
;
import
org.sss.presentation.noui.util.RedisUtil
;
import
org.sss.presentation.noui.util.StringUtil
;
import
org.sss.presentation.noui.util.StringUtil
;
import
com.google.gson.Gson
;
import
log.Log
;
import
log.LogFactory
;
public
class
AbstractCommonController
{
public
class
AbstractCommonController
{
protected
static
final
Log
log
=
LogFactory
.
getLog
(
AbstractCommonController
.
class
);
protected
static
final
Log
log
=
LogFactory
.
getLog
(
AbstractCommonController
.
class
);
...
@@ -49,38 +44,37 @@ public class AbstractCommonController {
...
@@ -49,38 +44,37 @@ public class AbstractCommonController {
protected
static
String
ON_STREAM_DOWNLOAD
=
"ON_STREAM_DOWNLOAD"
;
protected
static
String
ON_STREAM_DOWNLOAD
=
"ON_STREAM_DOWNLOAD"
;
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
public
Object
event
(
String
mappingUrl
,
String
eventType
,
Map
<
String
,
Object
>
dataMap
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
Object
event
(
String
mappingUrl
,
String
eventType
,
MultipartFile
file
,
Map
<
String
,
Object
>
dataMap
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
NoUiContext
context
=
null
;
NoUiContext
context
=
null
;
Result
ret
=
null
;
Result
ret
=
null
;
boolean
isMultipart
=
false
;
FileItem
lastFileItem
=
null
;
try
{
try
{
isMultipart
=
ServletFileUpload
.
isMultipartContent
(
request
);
//
isMultipart = ServletFileUpload.isMultipartContent(request);
if
(
isMultipart
)
{
//
if (isMultipart) {
//
ServletFileUpload
upload
=
new
ServletFileUpload
(
new
DiskFileItemFactory
());
//
ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
// Parse the request
//
// Parse the request
List
<
FileItem
>
items
=
upload
.
parseRequest
(
request
);
//
List<FileItem> items = upload.parseRequest(request);
Iterator
<
FileItem
>
iter
=
items
.
iterator
();
//
Iterator<FileItem> iter = items.iterator();
//
while
(
iter
.
hasNext
())
{
//
while (iter.hasNext()) {
FileItem
item
=
iter
.
next
();
//
FileItem item = iter.next();
// 普通表单域
//
// 普通表单域
if
(
item
.
isFormField
())
{
//
if (item.isFormField()) {
String
itemName
=
item
.
getFieldName
();
//
String itemName = item.getFieldName();
String
itemValue
=
item
.
getString
();
//
String itemValue = item.getString();
log
.
info
(
"文件表单 key:"
+
itemName
+
",Value:"
+
itemValue
);
//
log.info("文件表单 key:" + itemName + ",Value:" + itemValue);
// 给dataMap赋值
//
// 给dataMap赋值
Map
<
String
,
?>
itemMap
=
new
Gson
().
fromJson
(
itemValue
,
Map
.
class
);
//
Map<String, ?> itemMap = new Gson().fromJson(itemValue, Map.class);
dataMap
.
put
(
itemName
,
itemMap
);
//
dataMap.put(itemName, itemMap);
}
else
{
// 文件域
//
} else { // 文件域
lastFileItem
=
item
;
//
lastFileItem = item;
}
//
}
}
//
}
}
else
{
//
} else {
log
.
info
(
"普通表单key-Value:"
+
dataMap
);
//
log.info("普通表单key-Value:" + dataMap);
}
//
}
NoUiRequest
noUiRequest
=
new
NoUiRequest
(
request
,
mappingUrl
,
dataMap
);
NoUiRequest
noUiRequest
=
new
NoUiRequest
(
request
,
mappingUrl
,
dataMap
);
context
=
NoUiContextManager
.
createNoUiContext
(
noUiRequest
);
context
=
NoUiContextManager
.
createNoUiContext
(
noUiRequest
);
Alias
alias
=
new
Alias
(
mappingUrl
);
Alias
alias
=
new
Alias
(
mappingUrl
);
...
@@ -117,14 +111,14 @@ public class AbstractCommonController {
...
@@ -117,14 +111,14 @@ public class AbstractCommonController {
((
IDatafield
<?>)
currentDataField
).
invokeCheckRules
(
context
);
((
IDatafield
<?>)
currentDataField
).
invokeCheckRules
(
context
);
}
}
}
}
}
else
if
(
eventType
.
equals
(
ON_STREAM_UPLOAD
)
&&
lastFileItem
!=
null
)
{
}
else
if
(
eventType
.
equals
(
ON_STREAM_UPLOAD
)
&&
file
!=
null
)
{
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
IDatafield
dataField
=
(
IDatafield
)
baseObject
(
context
,
noUiRequest
,
alias
);
IDatafield
dataField
=
(
IDatafield
)
baseObject
(
context
,
noUiRequest
,
alias
);
IStream
stream
=
(
IStream
)
dataField
.
getValue
();
IStream
stream
=
(
IStream
)
dataField
.
getValue
();
stream
.
setName
(
lastFileItem
.
getName
());
stream
.
setName
(
file
.
getName
());
stream
.
setType
(
lastFileItem
.
getContentType
());
stream
.
setType
(
file
.
getContentType
());
IOUtils
.
copy
(
lastFileItem
.
getInputStream
(),
stream
.
getOutputStream
(),
1024
);
log
.
info
(
"文件表单 key:"
+
file
.
getName
()
+
",size:"
+
file
.
getSize
()
);
// dataField.setValue(stream
);
IOUtils
.
copy
(
file
.
getInputStream
(),
stream
.
getOutputStream
(),
1024
);
dataField
.
invokeEventRules
(
context
,
EventType
.
ON_STREAM_UPLOAD
,
null
);
dataField
.
invokeEventRules
(
context
,
EventType
.
ON_STREAM_UPLOAD
,
null
);
}
else
if
(
eventType
.
equals
(
ON_STREAM_DOWNLOAD
))
{
}
else
if
(
eventType
.
equals
(
ON_STREAM_DOWNLOAD
))
{
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
...
...
src/main/resources/spring-mvc.xml
View file @
2f926f92
...
@@ -26,7 +26,11 @@
...
@@ -26,7 +26,11 @@
<bean
class=
"org.sss.presentation.noui.jwt.TokenInterceptor"
></bean>
<bean
class=
"org.sss.presentation.noui.jwt.TokenInterceptor"
></bean>
</mvc:interceptor>
</mvc:interceptor>
</mvc:interceptors>
</mvc:interceptors>
<bean
id=
"multipartResolver"
class=
"org.springframework.web.multipart.commons.CommonsMultipartResolver"
>
<property
name=
"maxUploadSize"
value=
"200000"
/>
<property
name=
"maxInMemorySize"
value=
"200000"
/>
</bean>
<!-- 配置自动扫描的包 -->
<!-- 配置自动扫描的包 -->
<context:component-scan
base-package=
"org.sss.presentation.noui.controller"
></context:component-scan>
<context:component-scan
base-package=
"org.sss.presentation.noui.controller"
></context:component-scan>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment