错误:xwork2.ActionContext;类文件的版本错误49.0 [英] Error : xwork2.ActionContext; class file has wrong version 49.0

查看:149
本文介绍了错误:xwork2.ActionContext;类文件的版本错误49.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误(1,32):无法访问类com.opensymphony.xwork2.ActionContext;类文件的版本49.0错误,应为45.3或46.0或47.0或48.0

Error(1,32): cannot access class com.opensymphony.xwork2.ActionContext; class file has wrong version 49.0, should be 45.3 or 46.0 or 47.0 or 48.0

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import java.util.Map;

public class loginAction extends ActionSupport 
{
private String userId;
  private String password;
  public String execute() throws Exception{

    if ("admin".equals(userId) && "admin".equals(password)) {
      Map session = ActionContext.getContext().getSession();
      session.put("logged-in","true");
            return SUCCESS;
        }
    else{
       return ERROR;
    }
    }

    public String logout() throws Exception {

    Map session = ActionContext.getContext().getSession();
    session.remove("logged-in");
        return SUCCESS;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }
}

推荐答案

这意味着您使用错误的Java版本(我认为49.0是Java 1.5)编译了一个类,并且在这种情况下,您尝试在较旧的Java-VM中运行它...

尝试将javac设置为针对较旧的版本进行编译,例如1.4,然后重试.

您可以在构建文件中进行设置-假设ant看起来像这样:

This means you compiled a class with the wrong java version (49.0 is Java 1.5, I think) and it seems in this case you try to run it in an older Java-VM...

Try to set the javac to compile for an older Version e.g. 1.4 and retry.

You can set this in your build files - assuming ant it would look like this:

<javac srcdir="


{src.dir}" destdir
{src.dir}" destdir="


{bin.dir}" 调试 =" span> 弃用 =" 关闭" 优化 关闭" 包括 **" =" 目标 =" 1.4" 是" memoryMaximumSize =" 编码 =" > < classpath =" build.classpath" / < /javac >
{bin.dir}" debug="on" deprecation="off" optimize="off" includes="**" source="1.4" target="1.4" fork="yes" memoryMaximumSize="256m" encoding="utf-8"> <classpath refid="build.classpath" /> </javac>





希望这会有所帮助,
干杯,阿恩特





Hope this helps,
Cheers, Arndt


这篇关于错误:xwork2.ActionContext;类文件的版本错误49.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆