<s:property>标签将html标签转义成&amp;字符

本文介绍了一个常见的Struts框架问题:当使用struts标签property显示包含HTML标签的内容时,这些标签会被默认转义,导致无法正常显示。为了解决这一问题,文章提供了一种简单的方法——通过设置escape属性为false来禁用转义。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

struts标签property默认会把将显示的字符串进行转义处理,所以,你要显示的内容含有html标签时就会被转义处理,无法显示出效果。

解决方法:在获取字段值时,加上escape="false",

如<s:property escape="false" value="#request.test.testDesc"/>

<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MainWindow</class> <widget class="QMainWindow" name="MainWindow"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>1200</width> <height>800</height> </rect> </property> <property name="windowTitle"> <string>手机销售管理系统</string> </property> <widget class="QWidget" name="centralwidget"> <layout class="QVBoxLayout" name="verticalLayout" stretch="0,1"> <item> <widget class="QTabWidget" name="tabWidget"> <property name="currentIndex"> <number>0</number> </property> <!-- 手机管理选项卡 --> <widget class="QWidget" name="tab_PhoneManage"> <layout class="QVBoxLayout" name="layout_PhoneMain"> <!-- 输入表单区域 --> <layout class="QGridLayout" name="grid_PhoneInput" spacing="10"> <item row="0" column="0"> <widget class="QLabel" name="label_PhoneID"> <property name="text"> <string>手机编号:</string> </property> </widget> </item> <item row="0" column="1"> <widget class="QLineEdit" name="txtPhoneID"> <property name="placeholderText"> <string>必填,20位以内</string> </property> </widget> </item> <item row="0" column="2"> <widget class="QLabel" name="label_Model"> <property name="text"> <string>手机型号:</string> </property> </widget> </item> <item row="0" column="3"> <widget class="QLineEdit" name="txtModel"/> </item> <item row="1" column="0"> <widget class="QLabel" name="label_Brand"> <property name="text"> <string>手机品牌:</string> </property> </widget> </item> <item row="1" column="1"> <widget class="QLineEdit" name="txtBrand"/> </item> <item row="1" column="2"> <widget class="QLabel" name="label_PPrice"> <property name="text"> <string>进价(元):</string> </property> </widget> </item> <item row="1" column="3"> <widget class="QDoubleSpinBox" name="txtPPrice"> <property name="minimum"> <double>0.00</double> </property> <property name="decimals"> <number>2</number> </property> </widget> </item> <item row="2" column="0"> <widget class="QLabel" name="label_Stock"> <property name="text"> <string>库存数量:</string> </property> </widget> </item> <item row="2" column="1"> <widget class="QSpinBox" name="txtStock"> <property name="minimum"> <number>0</number> </property> </widget> </item> </layout> <!-- 操作按钮区域 --> <layout class="QHBoxLayout" name="layout_PhoneBtns" spacing="20"> <item> <widget class="QPushButton" name="btnAddPhone"> <property name="text"> <string>添加手机</string> </property> <property name="iconSize"> <size> <width>20</width> <height>20</height> </size> </property> </widget> </item> <item> <widget class="QPushButton" name="btnModifyPhone"> <property name="text"> <string>修改信息</string> </property> </widget> </item> <item> <widget class="QPushButton" name="btnDeletePhone"> <property name="text"> <string>删除手机</string> </property> </widget> </item> <item> <widget class="QPushButton" name="btnRefreshPhone"> <property name="text"> <string>刷新列表</string> </property> </widget> </item> </layout> <!-- 手机信息表格 --> <widget class="QTableWidget" name="tablePhoneList"> <property name="columnCount"> <number>5</number> </property> <property name="rowCount"> <number>0</number> </property> <column> <property name="text"> <string>编号</string> </property> </column> <column> <property name="text"> <string>型号</string> </property> </column> <column> <property name="text"> <string>品牌</string> </property> </column> <column> <property name="text"> <string>进价(元)</string> </property> </column> <column> <property name="text"> <string>库存</string> </property> </column> <property name="alternatingRowColors"> <bool>true</bool> </property> </widget> </layout> <property name="title"> <string>手机管理</string> </property> </widget> <!-- 销售管理选项卡 --> <widget class="QWidget" name="tab_SaleManage"> <layout class="QVBoxLayout" name="layout_SaleMain"> <!-- 销售输入表单 --> <layout class="QGridLayout" name="grid_SaleInput" spacing="10"> <item row="0" column="0"> <widget class="QLabel" name="label_SaleID"> <property name="text"> <string>手机编号:</string> </property> </widget> </item> <item row="0" column="1"> <widget class="QLineEdit" name="txtSaleID"> <property name="placeholderText"> <string>需与手机编号一致</string> </property> </widget> </item> <item row="0" column="2"> <widget class="QLabel" name="label_SPrice"> <property name="text"> <string>销售单价:</string> </property> </widget> </item> <item row="0" column="3"> <widget class="QDoubleSpinBox" name="txtSPrice"> <property name="minimum"> <double>0.00</double> </property> <property name="decimals"> <number>2</number> </property> </widget> </item> <item row="1" column="0"> <widget class="QLabel" name="label_SaleNum"> <property name="text"> <string>销售数量:</string> </property> </widget> </item> <item row="1" column="1"> <widget class="QSpinBox" name="txtSaleNum"> <property name="minimum"> <number>1</number> </property> </widget> </item> <item row="1" column="2"> <widget class="QLabel" name="label_SaleDate"> <property name="text"> <string>销售日期:</string> </property> </widget> </item> <item row="1" column="3"> <widget class="QDateEdit" name="dateSale"> <property name="displayFormat"> <string>yyyy-MM-dd</string> </property> <property name="calendarPopup"> <bool>true</bool> </property> <property name="date"> <date> <year>2024</year> <month>1</month> <day>1</day> </date> </property> </widget> </item> </layout> <!-- 销售操作按钮 --> <layout class="QHBoxLayout" name="layout_SaleBtns" spacing="20"> <item> <widget class="QPushButton" name="btnAddSale"> <property name="text"> <string>添加销售记录</string> </property> </widget> </item> <item> <widget class="QPushButton" name="btnRefreshSale"> <property name="text"> <string>刷新销售记录</string> </property> </widget> </item> </layout> <!-- 销售信息表格 --> <widget class="QTableWidget" name="tableSaleList"> <property name="columnCount"> <number>6</number> </property> <property name="rowCount"> <number>0</number> </property> <column> <property name="text"> <string>编号</string> </property> </column> <column> <property name="text"> <string>型号</string> </property> </column> <column> <property name="text"> <string>品牌</string> </property> </column> <column> <property name="text"> <string>单价(元)</string> </property> </column> <column> <property name="text"> <string>数量</string> </property> </column> <column> <property name="text"> <string>销售日期</string> </property> </column> <property name="alternatingRowColors"> <bool>true</bool> </property> </widget> </layout> <property name="title"> <string>销售管理</string> </property> </widget> <!-- 查询统计选项卡 --> <widget class="QWidget" name="tab_Statistics"> <layout class="QVBoxLayout" name="layout_StatMain" spacing="15"> <!-- 查询条件区域 --> <layout class="QGridLayout" name="grid_StatInput" spacing="10"> <item row="0" column="0"> <widget class="QLabel" name="label_SearchID"> <property name="text"> <string>按编号查询:</string> </property> </widget> </item> <item row="0" column="1"> <widget class="QLineEdit" name="txtSearchID"/> </item> <item row="0" column="2"> <widget class="QPushButton" name="btnSearchID"> <property name="text"> <string>查询</string> </property> </widget> </item> <item row="1" column="0"> <widget class="QLabel" name="label_StatBrand"> <property name="text"> <string>按品牌统计:</string> </property> </widget> </item> <item row="1" column="1"> <widget class="QLineEdit" name="txtStatBrand"/> </item> <item row="1" column="2"> <widget class="QPushButton" name="btnStatBrand"> <property name="text"> <string>统计</string> </property> </widget> </item> </layout> <!-- 结果显示区域 --> <widget class="QTextBrowser" name="txtStatResult"> <property name="minimumSize"> <size> <width>0</width> <height>200</height> </size> </property> <property name="placeholderText"> <string>查询/统计结果将显示在此...</string> </property> </widget> </layout> <property name="title"> <string>查询统计</string> </property> </widget> <!-- 排序管理选项卡 --> <widget class="QWidget" name="tab_Sort"> <layout class="QVBoxLayout" name="layout_SortMain"> <layout class="QHBoxLayout" name="layout_SortBtns" spacing="30"> <item> <widget class="QPushButton" name="btnSortPrice"> <property name="text"> <string>按进价排序(升序)</string> </property> <property name="minimumSize"> <size> <width>150</width> <height>40</height> </size> </property> </widget> </item> <item> <widget class="QPushButton" name="btnSortDate"> <property name="text"> <string>按销售日期排序(最近优先)</string> </property> <property name="minimumSize"> <size> <width>150</width> <height>40</height> </size> </property> </widget> </item> </layout> <widget class="QLabel" name="label_SortTip"> <property name="text"> <string>注:排序后自动刷新对应表格数据</string> </property> <property name="styleSheet"> <string>color: #666; font-size: 12px;</string> </property> </widget> </layout> <property name="title"> <string>排序管理</string> </property> </widget> </widget> </item> </layout> </widget> <widget class="QMenuBar" name="menubar"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>1200</width> <height>26</height> </rect> </property> <widget class="QMenu" name="menuFile"> <property name="title"> <string>文件</string> </property> <addaction name="actionSave"/> <addaction name="actionLoad"/> </widget> <addaction name="menuFile"/> </widget> <widget class="QStatusBar" name="statusbar"/> </widget> <action name="actionSave"> <property name="text"> <string>保存数据</string> </property> </action> <action name="actionLoad"> <property name="text"> <string>加载数据</string> </property> </action> <resources/> <connections/> </ui> 该ui文件读取第28行72列时出错,请改正并给出修改后的ui文件
最新发布
07-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值