小弟是新手,在调试CAS传递多个中文参数时出现了 乱码,并且修改WEB-INF/view/jsp/protocol/2.0/casServiceValidationSuccess.jsp该文件,顶部加上一行<%@page pageEncoding="UTF-8"%>,后返回如下错误,我的服务器用的是 cas-3.3.5 客户端用的是cas-client -3.0.10 ,打开WEB-INF/view/jsp/protocol/2.0/casServiceValidationSuccess.jsp文件删除“<%@page pageEncoding="UTF-8"%>”恢复正常,能够拿到数据了,但还是乱码。HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessagedescriptionThe server encountered an internal error () that prevented it from fulfilling this request.exception javax.servlet.ServletException: org.jasig.cas.client.validation.TicketValidationException: No principal was found in the response from the CAS server.
root cause org.jasig.cas.client.validation.TicketValidationException: No principal was found in the response from the CAS server.
note The full stack traces of the exception and its root causes are available in the GlassFish v3 logs.

解决方案 »

  1.   

    传递一个中文参数行不?
    以前能传递不?
    不如先uriencode成英文字符串
    传递过来了再解码
      

  2.   

     cas2.0协议的验证结果页面是通过目录:cas/WEB-INF/view/jsp/protocol/2.0/ 下定义的jsp(jstlview)模板页面来定义的。
        casProxySuccessView.jsp:对应验证成功的页面(这个页面还包含用户登录的帐户名)。
        casServiceValidationFailure.jsp:对应验证失败页面。
        乱码解决办法:
        在casProxySuccessView.jsp和casServiceValidationFailure.jsp页面代码的最前面加上:<%@page pageEncoding="pagecharset"%>
        其中pagecharset为页面编码,可以换为你想要的编码(GBK或是gb2312或是utf-8)。    如果还不行,试试下面两步:    1)修改CAS登陆验证页面的编码,如果你没换过这个主题的话,默认的是修改WEB-INF\view\jsp\default\ui\casLoginView.jsp文件,在最上面加上<%@ page pageEncoding="gb2312"%>。这里要特别注意一下,这个页面的编码要和上面XML文件里写的编码一致。    2)修改验证成功后做跳转的页面。也就是WEB-INF\ view\ jsp\ protocol\ 2.0\ casServiceValidationSuccess.jsp文件,在最上面加上<%@ page pageEncoding="UTF-8"%>。这里特别注意的是这个页面的编码要和你跳转过去的那个页面的编码一致,换句话说,客户端的验证页面的编码要和这个地方的一致,不一致的话,要转换一下。
      

  3.   

    请这样修改如XML/HTML代码: 
    <c:if test="${fn:length(assertion.chainedAuthentications[fn:length(assertion.chainedAuthentications)-1].principal.attributes) > 0}"> 
    <cas:attributes> 
    <c:forEach var="attr" items="${assertion.chainedAuthentications[fn:length(assertion.chainedAuthentications)-1].principal.attributes}">
    <c:set var="key" value="${fn:escapeXml(attr.key)}" scope="request"> 
    <c:set var="value" value="${fn:escapeXml(attr.value)}" scope="request"> 
    <cas:${key}><%=URLEncoder.encode((String)request.getattribute("value"),"UTF-8")%></cas:${key}> 
    </c:forEach> 
    </cas:attributes> 
    </c:if> 我已经帮你调试通过。然后又到客户端用URLDecoder.decode()解码.--结贴吧。呵呵
      

  4.   

    为什么 我php客户端 通过getuser()获取中文无乱码,而java客户端通过request.getRemoteUser()乱码了,在线急等。
      

  5.   

    楼主知道怎么修改登录页面提示信息吗,就是如果用户名输入错误,或者用户不存在,或者密码输入错误的似乎,报出的错误信息要不一样,怎么样实现呢。我看就是登录页面里面的<form:errors path="*" cssClass="errors" id="status" element="div"  />这一句来显示错误信息的,错误信息都是用的messages_zh_CN.properties这个文件中的error.authentication.credentials.bad这个信息,具体怎么让这个信息变动呢?