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
277eac95
Commit
277eac95
authored
May 30, 2019
by
gechengyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
8fdd4fb5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
2 deletions
+34
-2
NoUiPresentation.java
...a/org/sss/presentation/noui/context/NoUiPresentation.java
+1
-0
AbstractCommonController.java
...resentation/noui/controller/AbstractCommonController.java
+33
-2
No files found.
src/main/java/org/sss/presentation/noui/context/NoUiPresentation.java
View file @
277eac95
...
...
@@ -140,6 +140,7 @@ public class NoUiPresentation extends AbstractNullPresentation {
public
final
void
popup
(
IPanel
popupPanel
)
{
// this.popupPanel = popupPanel;
popupPanel
.
invokeDefaultRules
(
this
.
ctx
);
}
// @SuppressWarnings({ "rawtypes", "unchecked" })
...
...
src/main/java/org/sss/presentation/noui/controller/AbstractCommonController.java
View file @
277eac95
package
org
.
sss
.
presentation
.
noui
.
controller
;
import
java.io.ByteArrayOutputStream
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -12,6 +13,10 @@ import javax.servlet.http.HttpServletResponse;
import
log.Log
;
import
log.LogFactory
;
import
org.apache.commons.fileupload.FileItemIterator
;
import
org.apache.commons.fileupload.FileItemStream
;
import
org.apache.commons.fileupload.servlet.ServletFileUpload
;
import
org.apache.commons.fileupload.util.Streams
;
import
org.apache.commons.io.IOUtils
;
import
org.sss.common.model.EventType
;
import
org.sss.common.model.IBaseObject
;
...
...
@@ -47,7 +52,30 @@ public class AbstractCommonController {
public
Object
event
(
String
mappingUrl
,
String
eventType
,
Map
<
String
,
Object
>
dataMap
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
NoUiContext
context
=
null
;
Result
ret
=
null
;
boolean
isMultipart
=
false
;
InputStream
fileStream
=
null
;
try
{
isMultipart
=
ServletFileUpload
.
isMultipartContent
(
request
);
if
(
isMultipart
)
{
ServletFileUpload
upload
=
new
ServletFileUpload
();
// Parse the request
FileItemIterator
iter
=
upload
.
getItemIterator
(
request
);
while
(
iter
.
hasNext
())
{
FileItemStream
item
=
iter
.
next
();
// 普通表单域
if
(
item
.
isFormField
())
{
String
itemName
=
item
.
getFieldName
();
String
itemValue
=
Streams
.
asString
(
item
.
openStream
());
// 给dataMap赋值
dataMap
.
put
(
itemName
,
itemValue
);
}
else
{
// 文件域
fileStream
=
item
.
openStream
();
}
}
}
NoUiRequest
noUiRequest
=
new
NoUiRequest
(
request
,
mappingUrl
,
dataMap
);
context
=
NoUiContextManager
.
createNoUiContext
(
noUiRequest
);
Alias
alias
=
new
Alias
(
mappingUrl
);
...
...
@@ -88,16 +116,19 @@ public class AbstractCommonController {
@SuppressWarnings
(
"rawtypes"
)
IDatafield
dataField
=
(
IDatafield
)
baseObject
(
context
,
noUiRequest
,
alias
);
IStream
stream
=
(
IStream
)
dataField
.
getValue
();
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
();
byte
[]
data
=
new
byte
[
1024
];
int
bytes
=
0
;
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
();
while
((
bytes
=
request
.
getInputStream
()
.
read
(
data
))
!=
-
1
)
{
if
(
fileStream
!=
null
)
{
while
((
bytes
=
fileStream
.
read
(
data
))
!=
-
1
)
{
bos
.
write
(
data
,
0
,
bytes
);
}
IOUtils
.
write
(
bos
.
toByteArray
(),
stream
.
getOutputStream
());
IOUtils
.
closeQuietly
(
bos
);
}
// dataField.setValue(stream);
dataField
.
invokeEventRules
(
context
,
EventType
.
ON_STREAM_UPLOAD
,
null
);
IOUtils
.
closeQuietly
(
fileStream
);
}
else
if
(
eventType
.
equals
(
ON_STREAM_DOWNLOAD
))
{
@SuppressWarnings
(
"rawtypes"
)
IDatafield
dataField
=
(
IDatafield
)
baseObject
(
context
,
noUiRequest
,
alias
);
...
...
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