當前位置: 首頁>>代碼示例>>Java>>正文


Java StringEscapeUtils.escapeHtml方法代碼示例

本文整理匯總了Java中org.apache.commons.lang.StringEscapeUtils.escapeHtml方法的典型用法代碼示例。如果您正苦於以下問題:Java StringEscapeUtils.escapeHtml方法的具體用法?Java StringEscapeUtils.escapeHtml怎麽用?Java StringEscapeUtils.escapeHtml使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang.StringEscapeUtils的用法示例。


在下文中一共展示了StringEscapeUtils.escapeHtml方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createGraphMethodNode

import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
/**
 * Creates the graph method node and sets the label, methodName, methodSignature, methodBody and nodeMethod attributes on the node.
 *
 * @param src
 * @author Shashank B S
 */
private void createGraphMethodNode(VFMethod src) {
	if (graph.getNode(src.getId() + "") == null) {
		Node createdNode = graph.addNode(src.getId() + "");
		String methodName = src.getSootMethod().getName();
		String escapedMethodName = StringEscapeUtils.escapeHtml(methodName);
		String escapedMethodSignature = StringEscapeUtils.escapeHtml(src.getSootMethod().getSignature());
		createdNode.setAttribute("ui.label", methodName);
		createdNode.setAttribute("nodeData.methodName", escapedMethodName);
		createdNode.setAttribute("nodeData.methodSignature", escapedMethodSignature);
		String methodBody = src.getBody().toString();
		methodBody = Pattern.compile("^[ ]{4}", Pattern.MULTILINE).matcher(methodBody).replaceAll(""); // remove indentation at line start
		methodBody = methodBody.replaceAll("\n{2,}", "\n"); // replace empty lines
		String escapedMethodBody = StringEscapeUtils.escapeHtml(methodBody);
		String hexColor = getCodeBackgroundColor();
		createdNode.setAttribute("nodeData.methodBody", "<code><pre style=\"color: #000000; background-color: #"+hexColor+"\">" + escapedMethodBody + "</pre></code>");
		createdNode.setAttribute("nodeMethod", src);
	}
}
 
開發者ID:VisuFlow,項目名稱:visuflow-plugin,代碼行數:25,代碼來源:GraphManager.java

示例2: checkStorageInfoOrSendError

import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
private boolean checkStorageInfoOrSendError(JNStorage storage,
    HttpServletRequest request, HttpServletResponse response)
    throws IOException {
  int myNsId = storage.getNamespaceID();
  String myClusterId = storage.getClusterID();
  
  String theirStorageInfoString = StringEscapeUtils.escapeHtml(
      request.getParameter(STORAGEINFO_PARAM));

  if (theirStorageInfoString != null) {
    int theirNsId = StorageInfo.getNsIdFromColonSeparatedString(
        theirStorageInfoString);
    String theirClusterId = StorageInfo.getClusterIdFromColonSeparatedString(
        theirStorageInfoString);
    if (myNsId != theirNsId || !myClusterId.equals(theirClusterId)) {
      String msg = "This node has namespaceId '" + myNsId + " and clusterId '"
          + myClusterId + "' but the requesting node expected '" + theirNsId
          + "' and '" + theirClusterId + "'";
      response.sendError(HttpServletResponse.SC_FORBIDDEN, msg);
      LOG.warn("Received an invalid request file transfer request from " +
          request.getRemoteAddr() + ": " + msg);
      return false;
    }
  }
  return true;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:27,代碼來源:GetJournalEditServlet.java

示例3: generate

import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
public static void generate(final long hashCode, final StringBuilder content, final CharSequence[] successors, boolean notescurl) {
	content.append("<html>\n<head></head>\n<body>\n");
	// This helps in making the page text different even for the same number
	// of URLs, but not always.
	content.append("<h1>").append((char)((hashCode & 0xF) + 'A')).append((char)((hashCode >>> 4 & 0xF) + 'A')).append((char)((hashCode >>> 8 & 0xF) + 'A')).append((char)((hashCode >>> 12 & 0xF) + 'A')).append("</h1>\n");
	for (final CharSequence s : successors) {
		String ref = s.toString();
		if (!notescurl) ref = StringEscapeUtils.escapeHtml(s.toString());
		content.append("<p>Lorem ipsum dolor sit amet <a href=\""
				+ ref
				+ "\">"
				+ ref
				+ "</a>, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n");
	}
	content.append("</body>\n</html>\n");
}
 
開發者ID:LAW-Unimi,項目名稱:BUbiNG,代碼行數:17,代碼來源:NamedGraphServerHttpProxy.java

示例4: GBUserGridRowDTO

import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
public GBUserGridRowDTO(User user) {
this.id = user.getUserId().toString();
this.rowName = StringEscapeUtils.escapeHtml(user.getLastName() + " " + user.getFirstName());
this.firstName = user.getFirstName();
this.lastName = user.getLastName();
this.login = user.getLogin();
this.setPortraitId(user.getPortraitUuid());
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:9,代碼來源:GBUserGridRowDTO.java

示例5: getActivityStatusStr

import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
/**
    * Returns the activity status string which is a reference to an image
    *
    * @param learnerProgress
    * @param activity
    * @return
    */
   private String getActivityStatusStr(LearnerProgress learnerProgress, Activity activity) {

final String IMAGES_DIR = Configuration.get(ConfigurationKeys.SERVER_URL) + "images";
if (learnerProgress != null) {
    byte statusByte = learnerProgress.getProgressState(activity);
    if (statusByte == LearnerProgress.ACTIVITY_ATTEMPTED && learnerProgress.getCurrentActivity() != null) {
	return "<i class='fa fa-cog' title='"
		+ StringEscapeUtils.escapeHtml(learnerProgress.getCurrentActivity().getTitle()) + "'></i>";
    } else if (statusByte == LearnerProgress.ACTIVITY_COMPLETED) {
	return "<i class='fa fa-check text-success'></i>";
    }
}
return "-";
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:22,代碼來源:GradebookService.java

示例6: getReflectionsJSON

import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
/**
    * Get Paged Reflections
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   public ActionForward getReflectionsJSON(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws IOException, ServletException, ToolException, JSONException {

Long toolSessionId = WebUtil.readLongParam(request, QaAppConstants.TOOL_SESSION_ID);

// paging parameters of tablesorter
int size = WebUtil.readIntParam(request, "size");
int page = WebUtil.readIntParam(request, "page");
Integer sortByName = WebUtil.readIntParam(request, "column[0]", true);
String searchString = request.getParameter("fcol[0]");

int sorting = QaAppConstants.SORT_BY_NO;
if (sortByName != null) {
    sorting = sortByName.equals(0) ? QaAppConstants.SORT_BY_USERNAME_ASC : QaAppConstants.SORT_BY_USERNAME_DESC;
}

//return user list according to the given sessionID
IQaService qaService = getQAService();
List<Object[]> users = qaService.getUserReflectionsForTablesorter(toolSessionId, page, size, sorting,
	searchString);

JSONArray rows = new JSONArray();
JSONObject responsedata = new JSONObject();
responsedata.put("total_rows", qaService.getCountUsersBySessionWithSearch(toolSessionId, searchString));

for (Object[] userAndReflection : users) {
    JSONObject responseRow = new JSONObject();
    responseRow.put("username", StringEscapeUtils.escapeHtml((String) userAndReflection[1]));
    if (userAndReflection.length > 2 && userAndReflection[2] != null) {
	String reflection = StringEscapeUtils.escapeHtml((String) userAndReflection[2]);
	responseRow.put(QaAppConstants.NOTEBOOK, reflection.replaceAll("\n", "<br>"));
    }
    rows.put(responseRow);
}
responsedata.put("rows", rows);
response.setContentType("application/json;charset=utf-8");
response.getWriter().print(new String(responsedata.toString()));
return null;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:49,代碼來源:QaMonitoringAction.java

示例7: escape

import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
public String escape(String s) {
    return StringEscapeUtils.escapeHtml(s);
}
 
開發者ID:ghaseminya,項目名稱:jbake-rtl-jalaali,代碼行數:4,代碼來源:JadeTemplateEngine.java

示例8: getHeader

import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
@Override    
public String getHeader(String name) {    
    return StringEscapeUtils.escapeHtml(super.getHeader(name));    
}
 
開發者ID:xiachuanshou,項目名稱:shop-manager,代碼行數:5,代碼來源:XssHttpServletRequestWrapper.java

示例9: getParameter

import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
@Override    
public String getParameter(String name) {    
    return StringEscapeUtils.escapeHtml(super.getParameter(name));    
}
 
開發者ID:xiachuanshou,項目名稱:shop-manager,代碼行數:5,代碼來源:XssHttpServletRequestWrapper.java

示例10: createControlFlowGraphNode

import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
/**
 * Creates the CFG node and sets the label, unit, escapedHTMLunit, unitType, inSet, outSet, color attributes.
 *
 * @param node
 * @author Shashank B S
 */
private void createControlFlowGraphNode(VFNode node) {
	if (graph.getNode(node.getId() + "") == null) {
		Node createdNode = graph.addNode(node.getId() + "");
		Unit unit = node.getUnit();
		String label = unit.toString();
		try {
			UnitFormatter formatter = UnitFormatterFactory.createFormatter(unit);
			//UnitFormatter formatter = new DefaultFormatter();
			label = formatter.format(unit, maxLength);
		} catch (Exception e) {
			logger.error("Unit formatting failed", e);
		}

		createdNode.setAttribute("ui.label", label);
		String str = unit.toString();
		String escapedNodename = StringEscapeUtils.escapeHtml(str);
		createdNode.setAttribute("unit", str);
		createdNode.setAttribute("nodeData.unit", escapedNodename);

		createdNode.setAttribute("nodeData.unitType", node.getUnit().getClass());
		String str1 = Optional.fromNullable(node.getVFUnit().getInSet()).or("n/a").toString();
		String nodeInSet = StringEscapeUtils.escapeHtml(str1);
		String str2 = Optional.fromNullable(node.getVFUnit().getOutSet()).or("n/a").toString();
		String nodeOutSet = StringEscapeUtils.escapeHtml(str2);

		createdNode.setAttribute("nodeData.inSet", nodeInSet);
		createdNode.setAttribute("nodeData.outSet", nodeOutSet);

		Map<String, String> customAttributes = node.getVFUnit().getHmCustAttr();
		String attributeData = "";
		if(!customAttributes.isEmpty())
		{
			Iterator<Entry<String, String>> customAttributeIterator = customAttributes.entrySet().iterator();
			while(customAttributeIterator.hasNext())
			{
				Entry<String, String> curr = customAttributeIterator.next();
				attributeData += curr.getKey() + " : " + curr.getValue();
				attributeData += "<br />";
			}
			createdNode.setAttribute(nodeAttributesString, attributeData);
		}

		createdNode.setAttribute("nodeUnit", node);
		Color nodeColor = new Color(new ProjectPreferences().getColorForNode(node.getUnit().getClass().getName().toString()));
		createdNode.addAttribute("ui.color", nodeColor);
	}
}
 
開發者ID:VisuFlow,項目名稱:visuflow-plugin,代碼行數:54,代碼來源:GraphManager.java

示例11: viewDirList

import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
private void viewDirList(ViewItemResource resource, FileHandle fileHandle, HttpServletResponse response)
	throws IOException
{
	final String dirPath = resource.getFileDirectoryPath();

	response.setContentType("text/html");

	try (PrintWriter writer = new PrintWriter(new PrintStream(response.getOutputStream())))
	{
		writer.print("<html><head></head><body><h1>");
		writer.print(CurrentLocale.get("viewitem.section.dirlistsection.tle"));
		writer.print("</h1><b>");
		writer.print(CurrentLocale.get("viewitem.section.dirlistsection.listing",
			StringEscapeUtils.escapeHtml(resource.getViewableItem().getItemdir() + dirPath)));
		writer.print("</b><ul id=\"listing\">\n");

		if( dirPath.length() == 0 )
		{
			String xml = StringEscapeUtils.escapeHtml(XML_NAME);
			writer.print("<li><a href=\"");
			writer.print(xml);
			writer.print("\">");
			writer.print(xml);
			writer.print("</a></li>\n");
		}

		FileEntry[] aszFileList = fileSystemService.enumerate(fileHandle, dirPath, null);
		if( !Check.isEmpty(aszFileList) )
		{
			for( FileEntry entry : aszFileList )
			{
				String szFile = entry.getName();
				szFile = URLUtils.urlEncode(szFile, false);
				String name = szFile;
				if( entry.isFolder() )
				{
					szFile += "/~";
				}
				writer.print("<li><a href=\"");
				writer.print(szFile);
				writer.print("\">");
				writer.print(name);
				writer.print("</a></li>");
			}
		}
		writer.print("</ul></body></html>");
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:49,代碼來源:DirListViewer.java

示例12: getAnswersJSON

import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
private ActionForward getAnswersJSON(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws JSONException, IOException {

Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID);
Long questionUid = WebUtil.readLongParam(request, SurveyConstants.ATTR_QUESTION_UID);

// paging parameters of tablesorter
int size = WebUtil.readIntParam(request, "size");
int page = WebUtil.readIntParam(request, "page");
Integer sortByName = WebUtil.readIntParam(request, "column[0]", true);
String searchString = request.getParameter("fcol[0]");

int sorting = SurveyConstants.SORT_BY_DEAFAULT;
if (sortByName != null) {
    sorting = sortByName.equals(0) ? SurveyConstants.SORT_BY_NAME_ASC : SurveyConstants.SORT_BY_NAME_DESC;
}

// return user list according to the given sessionID
ISurveyService service = getSurveyService();
SurveyQuestion question = service.getQuestion(questionUid);
List<Object[]> users = service.getQuestionAnswersForTablesorter(sessionId, questionUid, page, size, sorting,
	searchString);

JSONArray rows = new JSONArray();
JSONObject responsedata = new JSONObject();
responsedata.put("total_rows", service.getCountUsersBySession(sessionId, searchString));

for (Object[] userAndAnswers : users) {

    JSONObject responseRow = new JSONObject();

    SurveyUser user = (SurveyUser) userAndAnswers[0];
    responseRow.put(SurveyConstants.ATTR_USER_NAME,
	    StringEscapeUtils.escapeHtml(user.getLastName() + " " + user.getFirstName()));
    responseRow.put(SurveyConstants.ATTR_USER_ID, user.getUserId());

    if (userAndAnswers.length > 1 && userAndAnswers[1] != null) {
	responseRow.put("choices", SurveyWebUtils.getChoiceList((String) userAndAnswers[1]));
    }
    if (userAndAnswers.length > 2 && userAndAnswers[2] != null) {
	// Data is handled differently in learner depending on whether
	// it is an extra text added
	// to a multiple choice, or a free text entry. So need to handle
	// the output differently.
	// See learner/result.jsp and its handling of question.type == 3
	// vs question.appendText
	String answer;
	if (question.getType() == SurveyConstants.QUESTION_TYPE_TEXT_ENTRY) {
	    // don't escape as it was escaped & BR'd before saving
	    answer = (String) userAndAnswers[2];
	} else {
	    // need to escape it, as it isn't escaped in the database
	    answer = StringEscapeUtils.escapeHtml((String) userAndAnswers[2]);
	    answer = answer.replaceAll("\n", "<br>");
	}
	responseRow.put("answerText", answer);
    }
    if (userAndAnswers.length > 3 && userAndAnswers[3] != null) {
	responseRow.put(SurveyConstants.ATTR_PORTRAIT_ID, ((Number)userAndAnswers[3]).longValue());
    }
    rows.put(responseRow);
}
responsedata.put("rows", rows);
response.setContentType("application/json;charset=utf-8");
response.getWriter().print(new String(responsedata.toString()));
return null;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:68,代碼來源:MonitoringAction.java

示例13: getReflectionsJSON

import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
private ActionForward getReflectionsJSON(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws JSONException, IOException {

Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID);

// paging parameters of tablesorter
int size = WebUtil.readIntParam(request, "size");
int page = WebUtil.readIntParam(request, "page");
Integer sortByName = WebUtil.readIntParam(request, "column[0]", true);
String searchString = request.getParameter("fcol[0]");

int sorting = SurveyConstants.SORT_BY_DEAFAULT;
if (sortByName != null) {
    sorting = sortByName.equals(0) ? SurveyConstants.SORT_BY_NAME_ASC : SurveyConstants.SORT_BY_NAME_DESC;
}

// return user list according to the given sessionID
ISurveyService service = getSurveyService();
List<Object[]> users = service.getUserReflectionsForTablesorter(sessionId, page, size, sorting, searchString);

JSONArray rows = new JSONArray();
JSONObject responsedata = new JSONObject();
responsedata.put("total_rows", service.getCountUsersBySession(sessionId, searchString));

for (Object[] userAndReflection : users) {

    JSONObject responseRow = new JSONObject();

    SurveyUser user = (SurveyUser) userAndReflection[0];
    responseRow.put(SurveyConstants.ATTR_USER_NAME,
	    StringEscapeUtils.escapeHtml(user.getLastName() + " " + user.getFirstName()));
    responseRow.put(SurveyConstants.ATTR_USER_ID, user.getUserId());
    
    if (userAndReflection.length > 1 && userAndReflection[1] != null) {
	String reflection = StringEscapeUtils.escapeHtml((String) userAndReflection[1]);
	responseRow.put(SurveyConstants.ATTR_REFLECTION, reflection.replaceAll("\n", "<br>"));
    }

    if (userAndReflection.length > 2 && userAndReflection[2] != null) {
	responseRow.put(SurveyConstants.ATTR_PORTRAIT_ID, ((Number)userAndReflection[2]).longValue());
    }

    rows.put(responseRow);
}
responsedata.put("rows", rows);
response.setContentType("application/json;charset=utf-8");
response.getWriter().print(new String(responsedata.toString()));
return null;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:50,代碼來源:MonitoringAction.java

示例14: toStringArray

import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
@Override
   public ArrayList<String> toStringArray(GBGridView view) {
ArrayList<String> ret = new ArrayList<String>();

ret.add(id.toString());

rowName = StringEscapeUtils.escapeHtml(rowName);

if (view == GBGridView.MON_COURSE) {
    if (gradebookMonitorURL != null && gradebookMonitorURL.length() != 0) {
	ret.add("<a href='javascript:launchPopup(\"" + gradebookMonitorURL + "\",\"" + rowName
		+ "\",1220,600)'>" + rowName + "</a>");
    } else {
	ret.add(rowName);
    }
    ret.add(subGroup);
    ret.add(startDate != null ? convertDateToString(startDate, null) : CELL_EMPTY);
    ret.add((medianTimeTaken != null && medianTimeTaken != 0) ? convertTimeToString(medianTimeTaken)
	    : CELL_EMPTY);
    ret.add((averageMark != null) ? GradebookUtil.niceFormatting(averageMark, displayMarkAsPercent) : CELL_EMPTY);

} else if ((view == GBGridView.LRN_COURSE) || (view == GBGridView.MON_USER)) {
    if (gradebookLearnerURL != null && gradebookLearnerURL.length() != 0) {
	ret.add("<a href='javascript:launchPopup(\"" + gradebookLearnerURL + "\",\"" + rowName + "\",796,570)'>"
		+ rowName + "</a>");
    } else {
	ret.add(rowName);
    }
    ret.add(subGroup);
    ret.add((status != null) ? status : CELL_EMPTY);
    ret.add(startDate != null ? convertDateToString(startDate, null) : CELL_EMPTY);
    ret.add(finishDate != null ? convertDateToString(finishDate, null) : CELL_EMPTY);
    ret.add(feedback);
    ret.add((medianTimeTaken != null && medianTimeTaken != 0)
	    ? toItalic(convertTimeToString(medianTimeTaken)) : CELL_EMPTY);
    ret.add((timeTaken != null) ? convertTimeToString(timeTaken) : CELL_EMPTY);
    ret.add((averageMark != null) ? toItalic(GradebookUtil.niceFormatting(averageMark, displayMarkAsPercent)) : CELL_EMPTY);
    ret.add((mark != null) ? GradebookUtil.niceFormatting(mark, displayMarkAsPercent) : CELL_EMPTY);

    //plain lesson list case
} else if (view == GBGridView.LIST) {
    ret.add(rowName);
}
return ret;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:46,代碼來源:GBLessonGridRowDTO.java

示例15: htmlEscape

import org.apache.commons.lang.StringEscapeUtils; //導入方法依賴的package包/類
/**
 * Html 轉碼.
 */
public static String htmlEscape(String html) {
	return StringEscapeUtils.escapeHtml(html);
}
 
開發者ID:wkeyuan,項目名稱:DWSurvey,代碼行數:7,代碼來源:EncodeUtils.java


注:本文中的org.apache.commons.lang.StringEscapeUtils.escapeHtml方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。