标题: [求助]还是特殊符号的过滤问题,用批处理生成网页
[打印本页]
作者: honghunter
时间: 2008-5-22 17:44
标题: [求助]还是特殊符号的过滤问题,用批处理生成网页
我现在的脚本如下:
@echo off
setlocal
:::eg.:http://192.168.0.60:9080/ReportCenter/frameset?__report=default.rptdesign&__reportxml=/report/xml/4.6.1.xml&condition=null
set "serverIP=http://192.168.0.60:9080"
set "baseUrl=%serverIP%/ReportCenter/frameset?__report=default.rptdesign^&__reportxml=/report/xml/"
set "urlSuffix=^&condition=null"
set "cache=b:"
set "template=B:\make_index\html1.txt"
set "htmlFilenam=%cache%\index.html"
type %template% >%htmlFilenam%
for /r %%i in (*.xml) do call:process %%i
echo ^</body^> >>%htmlFilenam%
echo ^</html^> >>%htmlFilenam%
goto:eof
:process
::::echo %1
echo fn %~n1%~x1
set "xml=%~n1%~x1"
set "url=%baseUrl%%xml%%urlSuffix%"
:::echo "url=%url%"
echo ^<a href="%url%"^>%url%^</a^>^<br/^> >>%htmlFilenam%
goto:eof
遇到的困难就是产生的index网页文件中的链接不对。
不明白为什么在地址部分的还有^符号,而显示部分正常(没有^符号)。
《a href=“地址部分”》显示部分《/a》。
<a href="http://192.168.0.60:9080/ReportCenter/frameset?__report=default.rptdesign^&__reportxml=/report/xml/4.1.10.xml^&condition=null">http://192.168.0.60:9080/ReportCenter/frameset?__report=default.rptdesign&__reportxml=/report/xml/4.1.10.xml&condition=null</a><br/>
作者: pusofalse
时间: 2008-5-22 17:49
批处理的瓶颈也在于此,特殊字符~
作者: lxmxn
时间: 2008-5-22 19:38
Quote: |
@echo off
setlocal
:::eg.:http://192.168.0.60:9080/ReportCenter/frameset?__report=default.rptdesign&__reportxml=/report/xml/4.6.1.xml&condition=null
set "serverIP=http://192.168.0.60:9080"
set "baseUrl=%serverIP%/ReportCenter/frameset?__report=default.rptdesign^&__reportxml=/report/xml/"
set "urlSuffix=^&condition=null"
set "cache=b:"
set "template=B:\make_index\html1.txt"
set "htmlFilenam=%cache%\index.html"
type %template% >%htmlFilenam%
for /r %%i in (*.xml) do call:process %%i
echo ^</body^> >>%htmlFilenam%
echo ^</html^> >>%htmlFilenam%
goto:eof
:process
::::echo %1
echo fn %~n1%~x1
set "xml=%~n1%~x1"
set "url=%baseUrl%%xml%%urlSuffix%"
:::echo "url=%url%"
echo ^<a href=^"%url%^"^>%url%^</a^>^<br/^> >>%htmlFilenam%
goto:eof |
|
[
Last edited by lxmxn on 2008-5-22 at 07:42 PM ]
作者: honghunter
时间: 2008-5-23 09:04
非常感谢!
不过还是没有明白原因,我再去查查资料。
作者: lxmxn
时间: 2008-5-23 10:55
因为第一个 %url% 是包含在双引号内的,在双引号的作用下,里面的 ^ 被原样的保留下来,而不是作为转义字符,所以会出现这个问题。