简体   繁体   English

如何发送从HTML表单到Servlet的路径?

[英]How to send a path from a HTML form to a servlet?

I want to send path(it is the path of a properties file) from a HTML form to the servlet. 我想从HTML表单发送路径(它是属性文件的路径)到servlet。 How would the servlet read the path?What should be the code to be written in the servlet? servlet如何读取路径?应该在servlet中编写什么代码?

I think you could solve this by doing something like this: 我认为您可以通过执行以下操作来解决此问题:

  <!DOCTYPE html>
  <html>
    <body>
      <form action="demo_form.asp">
        First name: <input type="text" name="fname"><br>
        <input type="hidden" name="country" value="Norway">
        <input type="submit" value="Submit">
      </form>
      <p>Notice that the hidden field above is not shown to a user.</p>
    </body>
 </html>

In your servlet You then call the doPost method and the .getParameter("country") The example above is from: http://www.w3schools.com/tags/att_input_type.asp I hope this is the solution for your problem 在您的servlet中,然后调用doPost方法和.getParameter(“ country”)上面的示例来自: http : //www.w3schools.com/tags/att_input_type.asp我希望这是解决您问题的方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM