首页 > 解决方案 > JSP:如何查找变量值是参数还是纯字符串

问题描述

我的 start.jsp 页面中有一个文本框,用户可以在其中提供任何静态值或要求从 db 中获取动态值,如图所示

在此处输入图像描述

@userEmail 是一个变量,其值将分配给“电子邮件”,我能够解析文本输入的静态部分,如下所示

  if ( testinput.length() != 0 ) {

   testinput.trim();

  if ( testinput.endsWith( "&" ) || testinput.endsWith( "?" ) ) {
    testinput = testinput.substring( 0, testinput.length() - 1 );
  
}
if ( testinput.startsWith( "&" ) || testinput.startsWith( "?" ) ) {
    testinput = testinput.substring(1);
}

if ( testinput.startsWith( " " ) ) {
    testinput = "";
}}

我不知道如何解决测试输入是字符串还是参数,并将其分配给变量值。

请帮我谈谈你的想法。

标签: javajsp

解决方案


推荐阅读