本文整理匯總了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;
}