当前位置: 首页>>代码示例>>Java>>正文


Java StringEscapeUtils.escapeJavaScript方法代码示例

本文整理汇总了Java中org.apache.commons.lang.StringEscapeUtils.escapeJavaScript方法的典型用法代码示例。如果您正苦于以下问题:Java StringEscapeUtils.escapeJavaScript方法的具体用法?Java StringEscapeUtils.escapeJavaScript怎么用?Java StringEscapeUtils.escapeJavaScript使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang.StringEscapeUtils的用法示例。


在下文中一共展示了StringEscapeUtils.escapeJavaScript方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: NotebookUserDTO

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
public NotebookUserDTO(NotebookUser user, NotebookEntry entry) {
this.uid = user.getUid();
this.loginName = user.getLoginName();
this.firstName = user.getFirstName();
this.lastName = user.getLastName();
this.finishedActivity = user.isFinishedActivity();
this.entryUID = user.getEntryUID();
if (user.getTeachersComment() != null) {
    this.teachersComment = StringEscapeUtils.escapeJavaScript(user.getTeachersComment());
}
this.entryDTO = new NotebookEntryDTO(entry);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:NotebookUserDTO.java

示例2: getHtmlOriginalContent

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
public String getHtmlOriginalContent(String originalContent, String escape) {
    originalContent = StringUtils.replace(originalContent, "\n", "<br>");
    originalContent = StringEscapeUtils.escapeJavaScript(originalContent);
    if ("HTML".equalsIgnoreCase(escape)) {
        originalContent = StringEscapeUtils.escapeHtml(originalContent);
        originalContent = StringUtils.replace(originalContent, "\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
        originalContent = StringUtils.replace(originalContent, "\\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
        return originalContent;
    } else {
        return originalContent;
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:13,代码来源:NumberFormatUtil.java

示例3: escapeQuotesInQuestionResult

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
private static void escapeQuotesInQuestionResult(AssessmentQuestionResult questionResult) {
String answerString = questionResult.getAnswerString();
if (answerString != null) {
    String answerStringEscaped = StringEscapeUtils.escapeJavaScript(answerString);
    questionResult.setAnswerStringEscaped(answerStringEscaped);
}

AssessmentQuestion question = questionResult.getAssessmentQuestion();
String title = question.getTitle();
if (title != null) {
    String titleEscaped = StringEscapeUtils.escapeJavaScript(title);
    question.setTitleEscaped(titleEscaped);
}

for (AssessmentQuestionOption option : question.getOptions()) {
    String questionStr = option.getQuestion();
    if (questionStr != null) {
	String questionEscaped = StringEscapeUtils.escapeJavaScript(questionStr);
	option.setQuestionEscaped(questionEscaped);
    }

    String optionStr = option.getOptionString();
    if (optionStr != null) {
	String optionEscaped = StringEscapeUtils.escapeJavaScript(optionStr);
	option.setOptionStringEscaped(optionEscaped);
    }
}
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:AssessmentEscapeUtils.java

示例4: NotebookEntryDTO

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
public NotebookEntryDTO(NotebookEntry entry) {
this.uid = entry.getUid();
this.entry = entry.getEntry();
if (this.entry != null) {
    this.entryEscaped = StringEscapeUtils.escapeJavaScript(this.entry);
}
this.createDate = entry.getCreateDate();
this.lastModified = (entry.getLastModified() == null) ? entry.getCreateDate() : entry.getLastModified();
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:NotebookEntryDTO.java

示例5: userMasterDetail

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/**
    * Populate user jqgrid table on summary page.
    */
   public ActionForward userMasterDetail(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {
IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext());

Long userUid = WebUtil.readLongParam(request, McAppConstants.USER_UID);
McQueUsr user = mcService.getMcUserByUID(userUid);
List<McUsrAttempt> userAttempts = mcService.getFinalizedUserAttempts(user);

// Escapes all characters that may brake JS code on assigning Java value to JS String variable (particularly
// escapes all quotes in the following way \").
if (userAttempts != null) {
    for (McUsrAttempt userAttempt : userAttempts) {
	McQueContent question = userAttempt.getMcQueContent();
	McOptsContent option = userAttempt.getMcOptionsContent();

	String questionText = question.getQuestion();
	if (questionText != null) {
	    String escapedQuestion = StringEscapeUtils.escapeJavaScript(questionText);
	    question.setEscapedQuestion(escapedQuestion);
	}

	String optionText = option.getMcQueOptionText();
	if (optionText != null) {
	    String escapedOptionText = StringEscapeUtils.escapeJavaScript(optionText);
	    option.setEscapedOptionText(escapedOptionText);
	}
    }
}

request.setAttribute(McAppConstants.ATTR_CONTENT, user.getMcSession().getMcContent());
request.setAttribute(McAppConstants.USER_ATTEMPTS, userAttempts);
request.setAttribute(McAppConstants.TOOL_SESSION_ID, user.getMcSession().getMcSessionId());
return (userAttempts == null || userAttempts.isEmpty()) ? null
	: mapping.findForward(McAppConstants.USER_MASTER_DETAIL);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:39,代码来源:McMonitoringAction.java

示例6: itemSummary

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
private ActionForward itemSummary(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

initializeScratchieService();
String sessionMapID = request.getParameter(ScratchieConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(sessionMapID);
request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID());

Long itemUid = WebUtil.readLongParam(request, ScratchieConstants.ATTR_ITEM_UID);
if (itemUid.equals(-1)) {
    return null;
}
ScratchieItem item = service.getScratchieItemByUid(itemUid);
request.setAttribute(ScratchieConstants.ATTR_ITEM, item);

Long contentId = (Long) sessionMap.get(ScratchieConstants.ATTR_TOOL_CONTENT_ID);
List<GroupSummary> summaryList = service.getQuestionSummary(contentId, itemUid);

// escape JS sensitive characters in answer descriptions
for (GroupSummary summary : summaryList) {
    for (ScratchieAnswer answer : summary.getAnswers()) {
	String description = (answer.getDescription() == null) ? ""
		: StringEscapeUtils.escapeJavaScript(answer.getDescription());
	answer.setDescription(description);
    }
}

request.setAttribute(ScratchieConstants.ATTR_SUMMARY_LIST, summaryList);
return mapping.findForward(ScratchieConstants.SUCCESS);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:MonitoringAction.java

示例7: getReflectionList

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
@Override
   public List<ReflectDTO> getReflectionList(Long contentId) {
ArrayList<ReflectDTO> reflections = new ArrayList<>();

// get all available leaders associated with this content as only leaders have reflections
List<ScratchieSession> sessionList = scratchieSessionDao.getByContentId(contentId);
for (ScratchieSession session : sessionList) {

    ScratchieUser leader = session.getGroupLeader();
    if (leader != null) {
	NotebookEntry notebookEntry = getEntry(session.getSessionId(), CoreNotebookConstants.NOTEBOOK_TOOL,
		ScratchieConstants.TOOL_SIGNATURE, leader.getUserId().intValue());
	if ((notebookEntry != null) && StringUtils.isNotBlank(notebookEntry.getEntry())) {
	    User user = new User();
	    user.setLastName(leader.getLastName());
	    user.setFirstName(leader.getFirstName());
	    ReflectDTO reflectDTO = new ReflectDTO(user);
	    reflectDTO.setGroupName(session.getSessionName());
	    String reflection = notebookEntry.getEntry();
	    reflection = StringEscapeUtils.escapeJavaScript(reflection);
	    reflectDTO.setReflection(reflection);
	    reflectDTO.setIsGroupLeader(session.isUserGroupLeader(leader.getUid()));

	    reflections.add(reflectDTO);
	}
    }
}

return reflections;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:31,代码来源:ScratchieServiceImpl.java


注:本文中的org.apache.commons.lang.StringEscapeUtils.escapeJavaScript方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。