2012-08-01 60 views
0

下面JSP顯示來自web服務產生java.io.IOException:沒有串行發現類

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<%@page import="com.action.AuraDecisionWorsheetDetailsService"%> 
<%@page import="com.action.AuraDecisionWorsheetDetailsServiceLocator"%> 

<HTML> 
<HEAD> 
<TITLE></TITLE> 
</HEAD> 
<BODY> 
<form name="form1" method="post" action='gawd.jsp'> 
<center><h1>DETAILS</h1></center> 

<% 
    try{ 
     AuraDecisionWorsheetDetailsService psi = new AuraDecisionWorsheetDetailsServiceLocator(); 

     com.action.AuraDecisionWorsheetDetails ps = psi.getAuraDecisionWorsheetDetails(); 

    if(request.getParameter("PolId")!=null){ 

     String pol_id=request.getParameter("PolId"); 


    %> 
     <center><b>RESULT :</b> <%= ps.service(pol_id)%></center> 
    <% }else 
     {%> 

    <TABLE align="center"> 
    <TR> 
     <TD>ENTER POLICY NUMBER</TD> 
     <TD><input type="text" name= "PolId" /></TD> 
    </TR> 
    <TR> 
     <TD colspan="2" align="center">&nbsp;</TD> 
    </TR> 
    <TR> 
     <TD colspan="2" align="center"><input type="submit" value="Submit"></TD> 
    </TR> 


    </TABLE>  
    <% } 
    }catch(Exception exe) 
    { 
     exe.printStackTrace(); 
    } 
    %> 

</form> 

</BODY> 
</HTML> 

返回的HashMap中值收到異常

faultString: java.io.IOException: No serializer found for class com.solcorp.pathfinder.uidefs.UIElement in registry [email protected] 

Caused by: java.io.IOException: No serializer found for class com.solcorp.pathfinder.uidefs.UIElement in registry [email protected] 

Web服務需要一個參數,即pol_id並返回以下HashMap中。 它使用Apache Axis創建。

回答

2

你在這個代碼這麼多的問題:

  1. 這是一個不好的做法,呼籲從JSP Web服務,你應該這樣做在servlet。 jsp應該主要集中在演示而不是邏輯上。嘗試使用jstl
  2. 您正在做alert(pol_id);而不打開任何腳本標記。 alert是一個javascript函數,必須包含在<script></script>之內。
  3. 你有這樣一行:<TD><input type="text" name= "PolId" %></TD>,這顯然應該是:<input type="text" name= "PolId" /></TD>(請注意,我在年底改變%/在這一行
  4. :。<%= ps.service(pol_id)%>你在年底失蹤;
  5. 你有這個條件:

    `if(request.getParameter("PolId")!=null){ 
        String pol_id=request.getParameter("PolId")==null?"":request.getParameter("PolId");}` 
    

    你在做相同的檢查兩次,或者刪除,如果還是三元運算符

解決這些問題(第一個問題實際上更多的是一個最佳實踐,因此您可以暫時跳過它),然後如果您有更多問題回來併發布您的問題。

編輯:在您的代碼 你Eching的從服務結果:

`<center><b>RESULT :</b> <%= ps.service(pol_id)%></center>` 

但正如你提到的是一個HashMap,所以我不認爲你可以直接呼應吧。你需要回應你從中提取值,所以嘗試做這個測試:

//in the java snippet 
Map map = ps.service(pol_id); 
... 
//in the html 
<center><b>RESULT :</b> <%= map.get(0)%></center> 
+0

@ flom2我所做的一切,除了1和4,仍然得到同樣的異常。 – happy 2012-08-01 09:29:09

+0

請用新代碼更新問題。 – Tomer 2012-08-01 09:31:42

+0

請參閱更新後的帖子 – happy 2012-08-01 09:35:41

相關問題