问一个Axis的中文问题
一个简单的Hello.jws如下:
public class Hello
{
public String hello(String name)
{
if(name==null)
name = "";
return "你好"+name+",欢迎来到Web服务的世界!";
}
}
本机调用http://localhost:8080/axis/Hello.jws?method=hello,得到以下结果(中文都成了? :():
<?xml version="1.0" encoding="UTF-8" ?>
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Body>
- <helloResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<helloReturn xsi:type="xsd:string">???????Web??????</helloReturn>
</helloResponse>
</soapenv:Body>
</soapenv:Envelope>
如果传入中文参数(http://localhost:8080/axis/Hello.jws?method=hello&name=路人甲),还会得到这个错误
<?xml version="1.0" encoding="UTF-8" ?>
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Body>
- <soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>java.io.UTFDataFormatException: Invalid byte 2 of 2-byte UTF-8 sequence.</faultstring>
<detail />
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
小弟初学Axis,还望各位大侠多多帮助:)