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


Java JavaScriptUtils.javaScriptEscape方法代码示例

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


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

示例1: doEndTagInternal

import org.springframework.web.util.JavaScriptUtils; //导入方法依赖的package包/类
/**
 * @see MessageTag#doStartTagInternal()
 * @should evaluate specified message resolvable
 * @should resolve message by code
 * @should resolve message in locale that different from default
 * @should return code if no message resolved
 * @should use body content as fallback if no message resolved
 * @should use text attribute as fallback if no message resolved
 * @should use body content in prior to text attribute as fallback if no message resolved
 * @should ignore fallbacks if tag locale differs from context locale
 */
@Override
protected int doEndTagInternal() throws JspException, IOException {
	try {
		// Resolve the unescaped message.
		String msg = resolveMessage();
		
		// HTML and/or JavaScript escape, if demanded.
		msg = isHtmlEscape() ? HtmlUtils.htmlEscape(msg) : msg;
		msg = this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(msg) : msg;
		
		// Expose as variable, if demanded, else write to the page.
		String resolvedVar = this.var;
		if (resolvedVar != null) {
			pageContext.setAttribute(resolvedVar, msg, TagUtils.getScope(this.scope));
		} else {
			writeMessage(msg);
		}
		
		return EVAL_PAGE;
	}
	catch (NoSuchMessageException ex) {
		throw new JspTagException(getNoSuchMessageExceptionDescription(ex));
	}
}
 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:36,代码来源:OpenmrsMessageTag.java

示例2: setAsText

import org.springframework.web.util.JavaScriptUtils; //导入方法依赖的package包/类
/**
 * override setAsText method , then register
 */
@Override
public void setAsText(String text) throws IllegalArgumentException {
	
	 if (!StringUtils.hasText(text)) {  
            return;  
        }else {
		String value = text;
		if (escapeHTML) {
			value = HtmlUtils.htmlEscape(value);
		}
		if (escapeJavaScript) {
			value = JavaScriptUtils.javaScriptEscape(value);
		}
		super.setValue(value);
	}
}
 
开发者ID:wenzhucjy,项目名称:GeneralUtils,代码行数:20,代码来源:StringEscapeEditor.java

示例3: createUrl

import org.springframework.web.util.JavaScriptUtils; //导入方法依赖的package包/类
/**
 * リンクとして出力するURLを生成します。
 * @param url パス
 * @param params パスに付与するパラメータ
 * @param pageContext ページコンテキスト
 * @param isHtmlEscape HTMLの特殊文字をエスケープするかどうか
 * @param isJavaScriptEscape JavaScriptの特殊文字をエスケープするかどうか
 * @return パス
 * @throws JspException 予期しない例外
 */
public static String createUrl(String url, Map<String, String[]> params, PageContext pageContext, boolean isHtmlEscape, boolean isJavaScriptEscape) throws JspException {
    HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
    HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();

    StringBuilder buffer = new StringBuilder();
    UrlType urlType = getUrlType(url);
    if (urlType == UrlType.CONTEXT_RELATIVE) {
        buffer.append(request.getContextPath());
        if (!url.startsWith("/")) {
            buffer.append("/");
        }
    }
    buffer.append(replaceUriTemplateParams(url, params, pageContext));
    buffer.append(createQueryString(params, (url.indexOf("?") == -1), pageContext));

    String urlStr = buffer.toString();
    if (urlType != UrlType.ABSOLUTE) {
        urlStr = response.encodeURL(urlStr);
    }

    urlStr = isHtmlEscape ? HtmlUtils.htmlEscape(urlStr) : urlStr;
    urlStr = isJavaScriptEscape ? JavaScriptUtils.javaScriptEscape(urlStr) : urlStr;

    return urlStr;
}
 
开发者ID:ctc-g,项目名称:sinavi-jfw,代码行数:36,代码来源:TagUtils.java

示例4: createUrl

import org.springframework.web.util.JavaScriptUtils; //导入方法依赖的package包/类
/**
 * Build the URL for the tag from the tag attributes and parameters.
 * @return the URL value as a String
 * @throws JspException
 */
private String createUrl() throws JspException {
	HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
	HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
	StringBuilder url = new StringBuilder();
	if (this.type == UrlType.CONTEXT_RELATIVE) {
		// add application context to url
		if (this.context == null) {
			url.append(request.getContextPath());
		}
		else {
			if (this.context.endsWith("/")) {
				url.append(this.context.substring(0, this.context.length() - 1));
			}
			else {
				url.append(this.context);
			}
		}
	}
	if (this.type != UrlType.RELATIVE && this.type != UrlType.ABSOLUTE && !this.value.startsWith("/")) {
		url.append("/");
	}
	url.append(replaceUriTemplateParams(this.value, this.params, this.templateParams));
	url.append(createQueryString(this.params, this.templateParams, (url.indexOf("?") == -1)));

	String urlStr = url.toString();
	if (this.type != UrlType.ABSOLUTE) {
		// Add the session identifier if needed
		// (Do not embed the session identifier in a remote link!)
		urlStr = response.encodeURL(urlStr);
	}

	// HTML and/or JavaScript escape, if demanded.
	urlStr = htmlEscape(urlStr);
	urlStr = this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(urlStr) : urlStr;

	return urlStr;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:43,代码来源:UrlTag.java

示例5: doAfterBody

import org.springframework.web.util.JavaScriptUtils; //导入方法依赖的package包/类
@Override
public int doAfterBody() throws JspException {
	try {
		String content = readBodyContent();
		// HTML and/or JavaScript escape, if demanded
		content = htmlEscape(content);
		content = this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(content) : content;
		writeBodyContent(content);
	}
	catch (IOException ex) {
		throw new JspException("Could not write escaped body", ex);
	}
	return (SKIP_BODY);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:EscapeBodyTag.java

示例6: getFrameFormat

import org.springframework.web.util.JavaScriptUtils; //导入方法依赖的package包/类
@Override
protected SockJsFrameFormat getFrameFormat(ServerHttpRequest request) {
	return new DefaultSockJsFrameFormat("<script>\np(\"%s\");\n</script>\r\n") {
		@Override
		protected String preProcessContent(String content) {
			return JavaScriptUtils.javaScriptEscape(content);
		}
	};
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:HtmlFileTransportHandler.java

示例7: getFrameFormat

import org.springframework.web.util.JavaScriptUtils; //导入方法依赖的package包/类
@Override
protected SockJsFrameFormat getFrameFormat(ServerHttpRequest request) {
	// We already validated the parameter above...
	String callback = getCallbackParam(request);

	return new DefaultSockJsFrameFormat("/**/" + callback + "(\"%s\");\r\n") {
		@Override
		protected String preProcessContent(String content) {
			return JavaScriptUtils.javaScriptEscape(content);
		}
	};
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:JsonpPollingTransportHandler.java

示例8: escapeJavascriptParam

import org.springframework.web.util.JavaScriptUtils; //导入方法依赖的package包/类
/**
 * 对javascript变量进行转义.
 * 
 * @param str
 *            js变量
 * @return 转义后的字符串
 */
public static String escapeJavascriptParam(String str) {
	if (str == null) {
		return null;
	}
	if (str.indexOf('"') != -1) {
		Exception e = new Exception("invalid js param:" + str);
		logger.error(e.getMessage(), e);
		str = str.replace("\"", "");
	}
	return JavaScriptUtils.javaScriptEscape(str);
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:19,代码来源:JstlFunctions.java

示例9: setAsText

import org.springframework.web.util.JavaScriptUtils; //导入方法依赖的package包/类
@Override
public void setAsText(String text) throws IllegalArgumentException {
    if (text == null) {
        setValue(null);
    } else {
        String value = text;
        if (escapeHTML) {
            value = HtmlUtils.htmlEscape(value);
        }
        if (escapeJavaScript) {
            value = JavaScriptUtils.javaScriptEscape(value);
        }
        setValue(value);
    }
}
 
开发者ID:wanghuizi,项目名称:fengduo,代码行数:16,代码来源:StringEscapeEditor.java

示例10: doStartTagInternal

import org.springframework.web.util.JavaScriptUtils; //导入方法依赖的package包/类
/**
 * Resolves the message, escapes it if demanded,
 * and writes it to the page (or exposes it as variable).
 * @see #resolveMessage()
 * @see org.springframework.web.util.HtmlUtils#htmlEscape(String)
 * @see org.springframework.web.util.JavaScriptUtils#javaScriptEscape(String)
 * @see #writeMessage(String)
 */
@Override
protected final int doStartTagInternal() throws JspException, IOException {
	try {
		// Resolve the unescaped message.
		String msg = resolveMessage();

		// HTML and/or JavaScript escape, if demanded.
		msg = isHtmlEscape() ? HtmlUtils.htmlEscape(msg) : msg;
		msg = this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(msg) : msg;

		// Expose as variable, if demanded, else write to the page.
		String resolvedVar = ExpressionEvaluationUtils.evaluateString("var", this.var, pageContext);
		if (resolvedVar != null) {
			String resolvedScope = ExpressionEvaluationUtils.evaluateString("scope", this.scope, pageContext);
			pageContext.setAttribute(resolvedVar, msg, TagUtils.getScope(resolvedScope));
		}
		else {
			writeMessage(msg);
		}

		return EVAL_BODY_INCLUDE;
	}
	catch (NoSuchMessageException ex) {
		throw new JspTagException(getNoSuchMessageExceptionDescription(ex));
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:35,代码来源:MessageTag.java

示例11: createUrl

import org.springframework.web.util.JavaScriptUtils; //导入方法依赖的package包/类
/**
 * Build the URL for the tag from the tag attributes and parameters.
 * @return the URL value as a String
 * @throws JspException
 */
private String createUrl() throws JspException {
	HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
	HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
	StringBuilder url = new StringBuilder();
	if (this.type == UrlType.CONTEXT_RELATIVE) {
		// add application context to url
		if (this.context == null) {
			url.append(request.getContextPath());
		}
		else {
			url.append(this.context);
		}
	}
	if (this.type != UrlType.RELATIVE && this.type != UrlType.ABSOLUTE && !this.value.startsWith("/")) {
		url.append("/");
	}
	url.append(replaceUriTemplateParams(this.value, this.params, this.templateParams));
	url.append(createQueryString(this.params, this.templateParams, (url.indexOf("?") == -1)));

	String urlStr = url.toString();
	if (this.type != UrlType.ABSOLUTE) {
		// Add the session identifier if needed
		// (Do not embed the session identifier in a remote link!)
		urlStr = response.encodeURL(urlStr);
	}

	// HTML and/or JavaScript escape, if demanded.
	urlStr = isHtmlEscape() ? HtmlUtils.htmlEscape(urlStr) : urlStr;
	urlStr = this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(urlStr) : urlStr;

	return urlStr;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:38,代码来源:UrlTag.java

示例12: doAfterBody

import org.springframework.web.util.JavaScriptUtils; //导入方法依赖的package包/类
@Override
public int doAfterBody() throws JspException {
	try {
		String content = readBodyContent();
		// HTML and/or JavaScript escape, if demanded
		content = isHtmlEscape() ? HtmlUtils.htmlEscape(content) : content;
		content = this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(content) : content;
		writeBodyContent(content);
	}
	catch (IOException ex) {
		throw new JspException("Could not write escaped body", ex);
	}
	return (SKIP_BODY);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:15,代码来源:EscapeBodyTag.java

示例13: testCaseExecutionToJSONObject

import org.springframework.web.util.JavaScriptUtils; //导入方法依赖的package包/类
private JSONObject testCaseExecutionToJSONObject(TestCaseExecution testCaseExecution) throws JSONException {
    JSONObject result = new JSONObject();
    result.put("ID", String.valueOf(testCaseExecution.getId()));
    result.put("QueueID", String.valueOf(testCaseExecution.getQueueID()));
    result.put("Test", JavaScriptUtils.javaScriptEscape(testCaseExecution.getTest()));
    result.put("TestCase", JavaScriptUtils.javaScriptEscape(testCaseExecution.getTestCase()));
    result.put("Environment", JavaScriptUtils.javaScriptEscape(testCaseExecution.getEnvironment()));
    result.put("Start", testCaseExecution.getStart());
    result.put("End", testCaseExecution.getEnd());
    result.put("Country", JavaScriptUtils.javaScriptEscape(testCaseExecution.getCountry()));
    result.put("Browser", JavaScriptUtils.javaScriptEscape(testCaseExecution.getBrowser()));
    result.put("ControlStatus", JavaScriptUtils.javaScriptEscape(testCaseExecution.getControlStatus()));
    result.put("ControlMessage", JavaScriptUtils.javaScriptEscape(testCaseExecution.getControlMessage()));
    result.put("Status", JavaScriptUtils.javaScriptEscape(testCaseExecution.getStatus()));
    result.put("NbExecutions", String.valueOf(testCaseExecution.getNbExecutions()));
    if (testCaseExecution.getQueueState() != null) {
        result.put("QueueState", JavaScriptUtils.javaScriptEscape(testCaseExecution.getQueueState()));
    }

    String bugId;
    String comment;
    String function;
    String shortDesc;
    if ((testCaseExecution.getTestCaseObj() != null) && (testCaseExecution.getTestCaseObj().getTest() != null)) {
        if (testCaseExecution.getApplicationObj() != null && testCaseExecution.getApplicationObj().getBugTrackerUrl() != null
                && !"".equals(testCaseExecution.getApplicationObj().getBugTrackerUrl()) && testCaseExecution.getTestCaseObj().getBugID() != null) {
            bugId = testCaseExecution.getApplicationObj().getBugTrackerUrl().replace("%BUGID%", testCaseExecution.getTestCaseObj().getBugID());
            bugId = new StringBuffer("<a href='")
                    .append(bugId)
                    .append("' target='reportBugID'>")
                    .append(testCaseExecution.getTestCaseObj().getBugID())
                    .append("</a>")
                    .toString();
        } else {
            bugId = testCaseExecution.getTestCaseObj().getBugID();
        }
        comment = JavaScriptUtils.javaScriptEscape(testCaseExecution.getTestCaseObj().getComment());
        function = JavaScriptUtils.javaScriptEscape(testCaseExecution.getTestCaseObj().getFunction());
        shortDesc = testCaseExecution.getTestCaseObj().getDescription();
    } else {
        bugId = "";
        comment = "";
        function = "";
        shortDesc = "";
    }
    result.put("BugID", bugId);

    result.put("Priority", JavaScriptUtils.javaScriptEscape(String.valueOf(testCaseExecution.getTestCaseObj().getPriority())));
    result.put("Comment", comment);
    result.put("Function", function);
    result.put("ShortDescription", shortDesc);

    result.put("Application", JavaScriptUtils.javaScriptEscape(testCaseExecution.getApplication()));

    return result;
}
 
开发者ID:cerberustesting,项目名称:cerberus-source,代码行数:57,代码来源:ReadTestCaseExecutionByTag.java

示例14: escapeJavascript

import org.springframework.web.util.JavaScriptUtils; //导入方法依赖的package包/类
/**
 * 对javascript特殊字符进行转义.
 * 
 * @param str
 *            javascript文本
 * @return 转义后的字符串
 */
public static String escapeJavascript(String str) {
	return JavaScriptUtils.javaScriptEscape(str);
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:11,代码来源:JstlFunctions.java

示例15: javaScript

import org.springframework.web.util.JavaScriptUtils; //导入方法依赖的package包/类
/**
 * 对值进行JavaScript转义
 *
 * @param input
 *            输入文本
 * @return 转义文本
 */
public String javaScript(String input) {
	return JavaScriptUtils.javaScriptEscape(input);
}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:11,代码来源:UtilsFunctionPackage.java


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