java - Html POST 方法不起作用

标签 java html post

为什么我的方法不起作用? 我的Java代码:

@POST
@Path("/request=PostStage")
@Produces(MediaType.APPLICATION_JSON)
public String getStagePOST(@QueryParam("fn")String fn,
    @QueryParam("tn")String tn,
    @QueryParam("stat")String stat,
    @QueryParam("length")String length,
    @QueryParam("lon")String lon,
    @QueryParam("lat")String lat,
    @QueryParam("crgw")String crgw,
    @QueryParam("lane")String lane) throws SQLException{
    return "Lat: " + lat + " lon: " + lon + " crgw: " + crgw;
}

我的 HTML 代码:

<form action="http://localhost:9090/services/stage/request=PostStage" method="POST">			
    <p>Localization:</p>
    <p> fn : <input  name="fn" /></p>
    <p> tn : <input  name="tn" /></p>
    <p>stat : <input  name="stat" /></p>
    <p>length : <input name="length" /></p>	
    <p>Geoposition:</p>
    <p>lon : <input name="lon" /></p>
    <p>lat : <input name="lat" /></p>
    <P> Other:</P>
    <p>crgw :  <input name = "crgw" /></p>
    <p> lane : <input  name="lane" /></p>
    <input type="submit" value="Searchh" />
</form> 

我给出了 html 页面中的参数示例:lon - 12、lat - 12 等。 结果,我得到:

Lat: null lon: null crgw: null

为什么?

我找不到问题:(

非常感谢您的所有回答。

最佳答案

输入标签上不应该有类型,例如 <input name="lon" type="text" />

还要验证表单中的 POST 是否确实包含参数,Chrome 和 Firefox 中的浏览器调试 IDE 可能能够看到 POST 请求的外观。

关于java - Html POST 方法不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31810680/

相关文章:

javascript - Ajax - 通过 ajax 将输入文件和附加变量发送到 php 文件

java - 关于 lilith(Logback 的日志查看器)的任何好的教程?

java - pom.xml 中的版本未更新

java - isCopy 字段在 android 中总是必需的吗?

javascript - 使用 div id 获取值到 Javascript 变量中

javascript - jQuery 无法设置超时

html - CSS 无法连接我的 HTML

java - 使用android中的Recycler View 同时与两组多图像进行数据绑定(bind)

php - 如何在外部域中使用 jQuery AJAX?

python - Post 在 python 解释器中运行时有效,但在保存为 .py 时出现 AttributeError