本文整理汇总了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);
}
示例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", " ");
originalContent = StringUtils.replace(originalContent, "\\t", " ");
return originalContent;
} else {
return originalContent;
}
}
示例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);
}
}
}
示例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();
}
示例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);
}
示例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);
}
示例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;
}