我有一个使用jsp和struts构建的Web应用程序,可以通过使用C#构建的可执行文件(.exe)与设备集成。
下面是我在jsp网页中的vbscript代码
sub launchApp()
Dim appShell
Set appShell = CreateObject("WScript.Shell")
Set WshUserEnv=appShell.Environment("System")
Dim applicantName,applicantsAddress
applicantName=document.getElementById("applicantName").value
applicantsAddress=document.getElementById("applicantsAddress").value
Dim items
/*
this is original code which is get value from input field in web browser
*/
'items = items & "" & applicantName & "" & "@#"
'items = items & "" & applicantsAddress & "" & "@#"
/*end original code*/
/*hard coded*/
items = items & "John Doe" & "@#"
items = items & "1st Avenue, LA" & "@#"
/*end hard coded*/
MsgBox items
'Waited for you to close the window before it continued.
appShell.Run WshUserEnv("applicationPath") & "\\application.exe " & items,1,True
Set appShell = Nothing
end sub
下面是c#sharp mainForm中以String [] arg为参数的代码
public string items = string.Empty;
public MainForm(string[] args)
{
InitializeComponent();
if (args.Length != 0)
{
items = args[0];
MessageBox.Show(items);
}
else
{
//do another logic
}
}
问题是当vbscript函数被触发/调用时,我传递了短语中包含空格的值,我放了MsgBox以确保短语正确传递了包含空格的内容,并且工作正常,起初我以为有一些东西我的原始代码有误
/*
this is original code which is get value from input field in web browser
*/
'items = items & "" & applicantName & "" & "@#"
'items = items & "" & applicantsAddress & "" & "@#"
/*end original code*/
它是从Web浏览器中的输入文件中检索值,也许我没有正确地结束String文字,所以我对值进行了硬编码,但是当涉及到c#Sharp程序时,String [] args仅在消息框时显示'John'被显示,而空格后的其余单词则不显示。
希望有人可以帮助我解决问题
谢谢并恭祝安康
这部分items = items & "" &
意味着您将用空字符串附加项目是无用的。因此,我想您想在其后附加双引号,以使带有空格的字符串被视为一个参数。您可以尝试以下方法:
items = items & """" & applicantName & """" & "@#"
items = items & """" & applicantsAddress & """" & "@#"
请注意,加倍引号是在VBScript中转义引号字符的方法
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句