Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
common
Project
Project
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
曲欣亮
common
Commits
41ff0eb1
Commit
41ff0eb1
authored
Oct 10, 2018
by
zhangyong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
e4af8797
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
2 deletions
+38
-2
StringUtil.java
src/main/java/com/egolm/common/StringUtil.java
+3
-1
ServletUtil.java
src/main/java/com/egolm/common/web/ServletUtil.java
+35
-1
No files found.
src/main/java/com/egolm/common/StringUtil.java
View file @
41ff0eb1
...
@@ -81,6 +81,8 @@ public class StringUtil {
...
@@ -81,6 +81,8 @@ public class StringUtil {
public
static
String
join
(
String
sign
,
String
before
,
Collection
<
String
>
strs
)
{
public
static
String
join
(
String
sign
,
String
before
,
Collection
<
String
>
strs
)
{
return
join
(
sign
,
before
,
""
,
strs
.
toArray
(
new
String
[
strs
.
size
()]));
return
join
(
sign
,
before
,
""
,
strs
.
toArray
(
new
String
[
strs
.
size
()]));
}
}
/**
/**
*
*
...
@@ -1013,5 +1015,5 @@ public class StringUtil {
...
@@ -1013,5 +1015,5 @@ public class StringUtil {
}
}
return
""
;
return
""
;
}
}
}
}
src/main/java/com/egolm/common/web/ServletUtil.java
View file @
41ff0eb1
package
com
.
egolm
.
common
.
web
;
package
com
.
egolm
.
common
.
web
;
import
java.net.InetAddress
;
import
java.net.InetAddress
;
import
java.net.URLDecoder
;
import
java.net.UnknownHostException
;
import
java.net.UnknownHostException
;
import
java.util.Enumeration
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.exception.PluginException
;
import
com.egolm.common.exception.PluginException
;
public
class
ServletUtil
{
public
class
ServletUtil
{
...
@@ -34,5 +37,36 @@ public class ServletUtil {
...
@@ -34,5 +37,36 @@ public class ServletUtil {
throw
new
PluginException
(
e
);
throw
new
PluginException
(
e
);
}
}
}
}
/**
*
* @Description 读取传入的json字符
* @param request
* @return
* @return String
* @throws
* @author 曲欣亮
* @date 2016年5月17日
* @since 2016年5月17日
*/
public
static
String
readReqJson
(
HttpServletRequest
request
)
{
String
json
=
""
;
try
{
Enumeration
<?>
names
=
request
.
getParameterNames
();
if
(
names
.
hasMoreElements
())
{
json
=
(
String
)
names
.
nextElement
();
}
if
(
json
==
null
||
json
.
length
()
==
0
)
{
json
=
StringUtil
.
read
(
request
.
getReader
());
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
try
{
String
encodeJson
=
URLDecoder
.
decode
(
json
,
"UTF-8"
);
return
encodeJson
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
json
;
}
}
}
}
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