为什么我的方法不起作用? 我的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/