Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何减少url长度?_Html_Jsp - Fatal编程技术网

Html 如何减少url长度?

Html 如何减少url长度?,html,jsp,Html,Jsp,我在href中传递变量,有些变量包含很多值。手机的特点 jsp代码: <% out.println("<a href='itemdetails.jsp?features="+p.getFeatures() +"&price="+p.getPrice()+"&pname="+p.getPname()+"&img="+p.getImg()+"'><div style='display: inline-block; background: url

我在
href
中传递变量,有些变量包含很多值。手机的特点

jsp代码:

<%
    out.println("<a href='itemdetails.jsp?features="+p.getFeatures() +"&price="+p.getPrice()+"&pname="+p.getPname()+"&img="+p.getImg()+"'><div style='display: inline-block; background: url("+p.getImg()+"); height: 200px; width: 200px;'></div></a>"); 
%>

所以url变得很长,是否有其他方法可以传递这些变量。通过使用
会话

尝试以下方法:

  • 将“a”标记替换为“input type='submit'” 如果需要,使按钮看起来像“a”标签
  • 将上述输入元素封装到带有“methodaspost”的表单元素中
  • 将不可见的“textarea名称”设置为带有名称标记的“myquerystring1”字段,将长url查询字符串(即itemdetails.jsp后面的.data)设置为textarea
  • 当用户单击submit按钮时,textarea内容将发布到itemdetails.jsp,名称为myquerystring1,您可以在这里捕获它们,做任何您想做的事情
  • 希望有帮助,祝你好运

    有关文本区域示例,请参见此链接

    请参阅此链接,了解如何在jsp中使用POST。

    更多信息,请参见此链接: