jsp中c:out的作用是什么 [英] what is c:out used for in jsp

查看:83
本文介绍了jsp中c:out的作用是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过类似

<c:out   something

</c:out>

这是做什么用的

推荐答案

它用于在考虑HTML/XML转义的同时打印服务器端变量.将其应用于用户控制的输入(请求参数,标头,Cookie,已保存的数据等)时,这将防止您的网站出现 XSS 攻击漏洞.

It is used to print server-side variables while taking HTML/XML escaping into account. When applying this on user-controlled input (request parameters, headers, cookies, saved data, etc), this will prevent your site from potential XSS attack holes.

如果要显示的数据绝不是由最终用户控制的,并且您使用的是JSP 2.0或更高版本(web.xml被声明为Servlet 2.4或更高版本,并且容器支持它),则可以也只需使用

If the data-to-be-displayed is in no way controlled by the enduser and you're using JSP 2.0 or newer (web.xml is declared as Servlet 2.4 or newer and the container supports it), then you can also just use

${bean.property}

代替

<c:out value="${bean.property}" />

另请参见:

  • Java/JSP中的XSS防护
  • XSS攻击如何真正起作用?
  • See also:

    • XSS prevention in Java/JSP
    • How does an XSS attack really work?
    • 这篇关于jsp中c:out的作用是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆