本文整理匯總了Java中org.apache.commons.lang.StringEscapeUtils.escapeSql方法的典型用法代碼示例。如果您正苦於以下問題:Java StringEscapeUtils.escapeSql方法的具體用法?Java StringEscapeUtils.escapeSql怎麽用?Java StringEscapeUtils.escapeSql使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang.StringEscapeUtils
的用法示例。
在下文中一共展示了StringEscapeUtils.escapeSql方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildNameSearch
import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
private void buildNameSearch(String searchString, StringBuilder sqlBuilder) {
if (!StringUtils.isBlank(searchString)) {
String[] tokens = searchString.trim().split("\\s+");
for (String token : tokens) {
String escToken = StringEscapeUtils.escapeSql(token);
sqlBuilder.append(" WHERE (user.first_name LIKE '%").append(escToken)
.append("%' OR user.last_name LIKE '%").append(escToken).append("%' OR user.login_name LIKE '%")
.append(escToken).append("%') ");
}
}
}
示例2: buildNameSearch
import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
private void buildNameSearch(StringBuilder queryText, String searchString) {
if (!StringUtils.isBlank(searchString)) {
String[] tokens = searchString.trim().split("\\s+");
for (String token : tokens) {
String escToken = StringEscapeUtils.escapeSql(token);
queryText.append(" AND (user.first_name LIKE '%").append(escToken)
.append("%' OR user.last_name LIKE '%").append(escToken).append("%' OR user.login_name LIKE '%")
.append(escToken).append("%')");
}
}
}
示例3: buildNameSearch
import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
private void buildNameSearch(String searchString, StringBuilder sqlBuilder, boolean whereDone) {
if (!StringUtils.isBlank(searchString)) {
String[] tokens = searchString.trim().split("\\s+");
for (String token : tokens) {
String escToken = StringEscapeUtils.escapeSql(token);
sqlBuilder.append(whereDone ? " AND ( " : " WHERE ( ")
.append("user.first_name LIKE '%").append(escToken)
.append("%' OR user.last_name LIKE '%").append(escToken).append("%' OR user.login_name LIKE '%")
.append(escToken).append("%') ");
}
}
}
示例4: getPagedUsers
import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
@Override
public List<Object[]> getPagedUsers(Long toolSessionId, Integer page, Integer size, int sorting,
String searchString) {
String GET_USERS_FOR_SESSION = "SELECT user.uid, user.hidden, CONCAT(user.firstName, ' ', user.lastName) FROM "
+ PeerreviewUser.class.getName() + " user WHERE user.session.sessionId = :toolSessionId ";
String sortingOrder = "";
switch (sorting) {
case PeerreviewConstants.SORT_BY_NO:
sortingOrder = " ORDER BY user.uid";
break;
case PeerreviewConstants.SORT_BY_USERNAME_ASC:
sortingOrder = " ORDER BY user.firstName ASC";
break;
case PeerreviewConstants.SORT_BY_USERNAME_DESC:
sortingOrder = " ORDER BY user.firstName DESC";
break;
}
StringBuilder bldr = new StringBuilder(GET_USERS_FOR_SESSION);
if (!StringUtils.isBlank(searchString)) {
String[] tokens = searchString.trim().split("\\s+");
for (String token : tokens) {
String escToken = StringEscapeUtils.escapeSql(token);
bldr.append(" AND ( ").append("user.firstName LIKE '%").append(escToken)
.append("%' OR user.lastName LIKE '%").append(escToken).append("%' OR user.loginName LIKE '%")
.append(escToken).append("%') ");
}
}
bldr.append(sortingOrder);
String queryString = bldr.toString();
Query query = getSession().createQuery(queryString)
.setLong("toolSessionId", toolSessionId);
if ( page != null && size != null ) {
query.setFirstResult(page * size).setMaxResults(size);
}
return (List<Object[]>) query.list();
}
示例5: buildNameSearch
import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
private void buildNameSearch(String searchString, StringBuilder sqlBuilder, boolean useWhere) {
if (!StringUtils.isBlank(searchString)) {
String[] tokens = searchString.trim().split("\\s+");
for (String token : tokens) {
String escToken = StringEscapeUtils.escapeSql(token);
sqlBuilder.append(useWhere ? " WHERE " : " AND ").append("(user.fullname LIKE '%").append(escToken)
.append("%' OR user.username LIKE '%").append(escToken).append("%') ");
}
}
}
示例6: buildCombinedSearch
import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
private void buildCombinedSearch(String searchStringVote, String searchStringUsername, StringBuilder sqlBuilder) {
if (!StringUtils.isBlank(searchStringVote)) {
String[] tokens = searchStringVote.trim().split("\\s+");
for (String token : tokens) {
String escToken = StringEscapeUtils.escapeSql(token);
sqlBuilder.append(" WHERE (userEntry LIKE '%").append(escToken).append("%') ");
}
} else {
buildNameSearch(searchStringUsername, sqlBuilder, true);
}
}
示例7: buildNameSearch
import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
private void buildNameSearch(String searchString, StringBuilder sqlBuilder) {
if (!StringUtils.isBlank(searchString)) {
String[] tokens = searchString.trim().split("\\s+");
for (String token : tokens) {
String escToken = StringEscapeUtils.escapeSql(token);
sqlBuilder.append(" AND (user.first_name LIKE '%").append(escToken)
.append("%' OR user.last_name LIKE '%").append(escToken).append("%' OR user.login_name LIKE '%")
.append(escToken).append("%') ");
}
}
}
示例8: buildNameSearch
import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
private String buildNameSearch(String searchString, String userRef) {
String filteredSearchString = null;
if (!StringUtils.isBlank(searchString)) {
StringBuilder searchStringBuilder = new StringBuilder("");
String[] tokens = searchString.trim().split("\\s+");
for (String token : tokens) {
String escToken = StringEscapeUtils.escapeSql(token);
searchStringBuilder.append(" AND (" + userRef + ".fullname LIKE '%").append(escToken)
.append("%' OR " + userRef + ".username LIKE '%").append(escToken).append("%') ");
}
filteredSearchString = searchStringBuilder.toString();
}
return filteredSearchString;
}
示例9: buildNameSearch
import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
private void buildNameSearch(StringBuilder queryText, String searchString) {
String filteredSearchString = null;
if (!StringUtils.isBlank(searchString)) {
String[] tokens = searchString.trim().split("\\s+");
for (String token : tokens) {
String escToken = StringEscapeUtils.escapeSql(token);
queryText.append(" WHERE (fullname LIKE '%").append(escToken).append("%' OR username LIKE '%")
.append(escToken).append("%') ");
}
}
}
示例10: strip
import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
/**
* @param value 待處理內容
* @return
* @Description SQL注入內容剝離
*/
public String strip(String value) {
//剝離SQL注入部分代碼
return StringEscapeUtils.escapeSql(value.replaceAll("('.+--)|(\\|)|(%7C)", ""));
}
示例11: escapeSql
import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
@Override
protected String escapeSql(String literalValue) {
String escaped = StringEscapeUtils.escapeSql(literalValue);
// we need to deal with a strange design with the \' escape but no \\ escape
return StringUtils.replace(escaped, "\\'", "'||TRIM('\\ ')||''");
}
示例12: escapeSql
import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
protected String escapeSql(String literalValue) {
return StringEscapeUtils.escapeSql(literalValue);
}