![](/img/trans.png)
[英]Java RESTFUL-Service returns 500 Internal Server Error (jersey)
[英]500 glassfish internal error while calling restful service with % sign in URL
我在glassfish 3.2.1上遇到HTTP 500内部服务器错误,同时将%符号放入URL作为ledgerAccountNumber。
Sample url - https://domain:8181/services/generalLedgerAccountConfig/isLedgerAccountNumberInUse/200%?_=1398694030799
周到的服务:
@Path("/generalLedgerAccountConfig")
public class ConfigGeneralLedgerAccount {
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("isLedgerAccountNumberInUse/{ledgerAccountNumber}")
public Response isLedgerAccountNumberInUse(@PathParam("ledgerAccountNumber") String ledgerAccountNumber) {
...
}
}
任何想法为什么会引发500 http错误?
%在URI路径中不是有效字符。 它代表一个不安全字符的ASCII码的开始,并且在路径中任何时候只要有一个“%”,后跟两位数字即可。 在此之后是“?”。
如果要将文字%发送给服务器,则需要将其转义为“%25”。 因此,您的客户端未正确编码URL。 无论客户端是什么,当它从用户那里获得输入时,都必须正确地对该URL进行编码,以消除非法字符或逃避合法字符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.