这种  <param name="contentType">image/jpg</param>
 写法难道有问题?

解决方案 »

  1.   

    应该还是类型的问题。 0.9759968174621463:
    Response Headersview source
    Cache-Control:no-cache
    Content-Length:1919
    Content-Type:image/jpeg;charset=UTF-8
    Date:Thu, 16 Jan 2014 06:02:28 GMT
    Expires:Thu, 01 Jan 1970 00:00:00 GMT
    Pragma:No-cache
    Proxy-Connection:keep-alive
    Server:Apache-Coyote/1.1
    X-Powered-By:Servlet 2.5; JBoss-5.0/JBossWeb-2.1
    X-Via:1.1 zjyw13:9 (Cdn Cache Server V2.0)
      

  2.   

    你这个是做了模拟么? 你action配置怎样的?
      

  3.   

    Content-Type:image/jpeg  应该是这样的。不过现在你不是这样的。
    你点这个看下返回头信息
    不知道你那里出问题。
      

  4.   

    没怎么用过struts,都是使用response指定contentType的,你这个配置我感觉不是对应response的
      

  5.   

    感谢大家的发言,@rui888,我是参考 你所给的http://blog.csdn.net/yao_qinwei/article/details/8244115这个链接里面的文章来操作的,经过我排查,居然居然是因为session引起的,具体还没弄明白,我使用ActionContext.getContext().getSession().put("authcode", authcode);将验证码放入session的时候页面可以正常,但是如果使用 session.put("authcode", authcode);的时候就会出现我所反映的问题…… 应该是这篇博客里面session经过spring DI注入的,而我没有做先关配置造成的  package com.ccnu.action;import java.io.ByteArrayInputStream;
    import java.util.Map;import com.ccnu.utils.ImageUtils;
    import com.ccnu.utils.RandomNumUtil;
    import com.ccnu.utils.SysLogUtils;
    import com.opensymphony.xwork2.ActionContext;
    import com.opensymphony.xwork2.ActionSupport;public class CreateImageAction extends ActionSupport { /**
     * 
     */
    private static final long serialVersionUID = 212375542572427219L; // 图片流
    private ByteArrayInputStream inputStream; // session域
    private Map<String, Object> session; public void setSession(Map<String, Object> session) {
    this.session = session;
    } public void setInputStream(ByteArrayInputStream inputStream) {
    this.inputStream = inputStream;
    } public ByteArrayInputStream getInputStream() {
    return inputStream;
    } @Override
    public String execute() throws Exception {
    // // 获取默认难度和长度的验证码
    String authcode = ImageUtils.getSecurityCode();
    SysLogUtils.info("系统生成验证码[" + authcode + "]");
    this.setInputStream(ImageUtils.getImageAsInputStream(authcode));
     ActionContext.getContext().getSession().put("authcode", authcode);// 使用这个能正常运行
    // 取得随机字符串放入HttpSession
    //session.put("authcode", authcode);  //使用这个的时候会出现我反应的问题
    return SUCCESS;
    }}
    谢谢大家的热心…… 
      

  6.   

    public String intercept(ActionInvocation invocation) throws Exception {
    final Object action = invocation.getAction();
    final ActionContext context = invocation.getInvocationContext();

    if (action instanceof SessionAware) {
    ((SessionAware) action)。setSession(context.getSession());
    }

    return invocation.invoke();
    }你这个 session.put("authcode", authcode);失败  是因为你的CreateImageAction  没实现 SessionAware   你实现看看