asp.mvc 中的渲染有什么区别
渲染服务器代码的运算符有什么区别?
Operator: <%@
Operator: <%:
Operator: <%=
What is the differences in operators for render server code?
Operator: <%@
Operator: <%:
Operator: <%=
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
<%=
只是计算一个表达式并将结果写入页面输出<%:
是相同的,而且 HTML 对输出进行编码 - 除非输出实现 IHtmlString<%@
用于特殊框架指令,例如 <%@ Page 用于指定页面属性,例如母版页<%
用于作为语句的代码块,不是表达。除非您显式调用写入输出的函数,否则它们不会生成页面输出。<%#
用于数据绑定表达式,当 Webforms 控件进行数据绑定时计算该表达式。因此它们很少在 MVC 中使用。<%=
simply evaluates an expression and writes the result to the page output<%:
is the same, but also HTML encodes the output - unless the output implements IHtmlString<%@
is for special framework directives, e.g. <%@ Page for specifying page attributes such as the master page<%
is for code blocks that are statements, not expressions. These will not generate page output unless you explicitly call a function that writes to the output.<%#
is for data-binding expressions, which are evaluated when a webforms control is databound. They are therefore rarely used in MVC.<%:对结果进行 html 编码
<%= 等于 Response.Write
<%@ 是预处理器指令
<%: html-encodes the result
<%= is equal to Response.Write
<%@ is an preprocessor derictive