2017-06-01 14 views
0

私はjavaを使い慣れています。 サーブレットにSOAP応答を受信しました。 JSPページに表示しようとすると、応答が正しく表示されません。これはJSPで石鹸の応答を表示

<?xml version="1.0" encoding="UTF-8"?> 
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
     <ns2:chargeResponse xmlns:ns2="http://p.com/"> 
     <return> 
      <referralDestination> 
       <address>919825010001</address> 
      </referralDestination> 
      <transactionId>REF59369</transactionId> 
      <transactionState>CONFIRMED</transactionState> 
     </return> 
     </ns2:chargeResponse> 
    </soap:Body> 
</soap:Envelope> 

RequestDispatcher dispatcher = req.getRequestDispatcher("response.jsp"); 
      req.setAttribute("result", soapResponse); 
      dispatcher.forward(req, resp); 

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
    pageEncoding="ISO-8859-1"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
<title>Insert title here</title> 
</head> 
<body> 
<h1> Response</h1> 
<table> 
    <tr> 
     <td><%=request.getAttribute("result")%></td> 
    </tr> 
</table> 
</body> 
</html> 

SOAP応答はここにあるresponse.jspでは、私がリクエストに添付応答を転送する方法である。しかしJSPの表示は、何であるか

919825010001 REF59369 CONFIRMED 
+0

がhttps://stackoverflow.com/questions/7519618/display-xml-content-in-html-page –

答えて

0

:XMLレスポンスタグ

試しを逃れるために、rawモードを使用してそれを印刷します。

<textarea rows="20" cols="40" style="border:none;"> 

      <%=request.getAttribute("result")%> 

</textarea> 
0

textareaは私のために働い使用

<%!=request.getAttribute("result")%> 

それとも、@ヨゼフ・chocholacekのコメントとしてテキストエリアを使用することができますが、提案

+0

を参照してください。<%!= request.getAttribute( "結果")%>は、エラーが発生します。しかし、@jozefの答えはうまくいった。試してくれてありがとう。 – cmb28

関連する問題