日期:2014-05-17  浏览次数:20642 次

XML、HTML、URL特殊字符的处理
不完全代码

  • form表单提交时,调用一个js函数将需要特殊处理的字段使用encodeURIComponent()方法进行编码。

<html>
    <form name="instantMgrSendForm" action="<%=path + jspCtxSer.getRequestServletUrl()%>" method="post" onsubmit="return validate()">
        <%=jspCtxSer.getRequiredHtmlHiddenFields(null,"sendInstantMgrFlow")%>
        <textarea id="body" name="body" style="width: 300px; height: 80px">
        </textarea>
        <input id="submit" value="发送" type="submit" />
    </form>
</html>

<script language="JavaScript" src="<%=path%>js/jquery.js"></script>
<script language="javascript">
	function validate(){
	$('#body').val(encodeURIComponent($('#body').val()));
        return true;	
	}
</script>

  • form表单提交后,后续处理交由业务流程sendInstantMgrFlow来处理

  • 业务流程sendInstantMgrFlow是处理一系列操作步骤的集合,在其中加入一步UrlDecodeStep

<?xml version="1.0" encoding="UTF-8"?>
<SelfDefTransFlow>
	<TransactionFlow id="sendInstantMgrFlow"
		transFlowContext="sendInstantMgrCtx"
		refTransTemplate="authCheckTransTemplate">
		<transStep id="UrlDecodeStep" names="body" enCoding="UTF-8"
			class="com.sunyard.cbif.sms.transSteps.UrlDecodeStep">
			<transition id="0" dest="next" />
			<transition id="Other" dest="setErrorPageStep" />
		</transStep>
		<transStep id="sendInstantMgrStep" fromNO="" funcode="SMS001"
			format="15"
			class="com.sunyard.cbif.sms.transSteps.SendInstantMgrStep">
			<transition id="0" dest="next" />
			<transition id="Other" dest="setErrorPageStep" />
		</transStep>
		<transStep id="sqlAccessTransStep" serviceName="getSYSData"
			targetScope="root">
			<transition id="0" dest="next" />
			<transition id="Other" dest="setErrorPageStep" />
		</transStep>		
		<transStep id="sendSMSBySocketStep" funcode="SMS001"
			class="com.sunyard.cbif.sms.transSteps.SendSMSBySocketStep">
			<transition id="0" dest="SetLogForSendInstantMgrStep" />
			<transition id="Other" dest="setErrorPageStep" />
		</transStep>
		<transStep id="setSuccessPageStep"
			class="com.sunyard.cbif.transSteps.SetReplyPageTransStep"
			on0Do="end"
			onOtherDo="setErrorPageStep"
			pageName="sms/instantMgrSendResult.jsp" />
		<transStep id="setErrorPageStep"
			class="com.sunyard.cbif.transSteps.SetReplyPageTransStep"
			onOtherDo="end" pageName="error.jsp" />
		<refFormat alias="inputSendMsgFmt" refId="inputSendMsgFmt" />
		<refFormat alias="outputSendMsgFmt" refId="outputSendMsgFmt" />
	</TransactionFlow>
	<context id="sendInstantMgrCtx" type="transFlow">
		<refKColl refId="sendInstantMgrColl" />
		<refService refId="getSYSData" />
	</context>
	<kColl id="sendInstantMgrColl">
		<iColl id="msgIColl">
			<kColl>
				<field id="funcode" des="功能码" />
				<field id="id" des="短信渠道自动为每一条新的短信生成,方便查询" />
				<field id="channel" des="发送请求的渠道应用在短信平台注册的编号" />
				<field id="type" des="短信类型:100宣传短信,101业务短信" />
				<field id="prio" des="短信发送优先级 0:普通1:重要2:最高" />
				<field id="sdate" des="短信的发送开始日期" />
				<field id="edate" des="短信的最迟发送日期" />
				<field id="stime" des="短信的发送开始时间" />
				<field id="etime" des="短信的最迟发送时间" />
				<field id="to" 
				  des="短信接受人的手机号码(发送给多个手机号码时,号码之间用“,”号分隔)" />
				<field id="sp" des="接收短信运营商" />
				<field id="from" des="短信的发送人的手机号码" />
				<field id="sender" des="短信发送者" />
				<field id="format" des="信息格式:15为普通短信" />
				<field id="body" des="短信的内容" />
			</kColl>
		</iColl>
	</kColl>
	<SQLAccessService id="getSYSData" dbResource="CBIFJDBC">
		&