struts2下在命令行编译Action类时报错---程序包com.opensymphony.xwork2不存在

inuyasha1 2014-11-23 01:38:18
我在命令行编译Action类的时候一直都是报错--程序包com.opensymphony.xwork2不存在,但是我是在WEB-INF/lib文件夹里面添加了struts的必要的几个这几个jar包的,这个问题困扰了我几天还是没有解决,希望大家可以帮我解决一下,谢谢啦。


package org.crazyit.app.action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport
{
//定义封装请求参数的username和password属性
private String username;
private String password;

public String getUsername()
{
return username;
}
public void setUsername(String username)
{
this.username = username;
}

public String getPassword()
{
return password;
}
public void setPassword(String password)
{
this.password = password;
}
//定义处理用户请求的execute方法
public String execute() throws Exception
{
//当username为crazyit.org,password为leegang时即登录成功
if (getUsername().equals("crazyit.org")
&& getPassword().equals("leegang") )
{
ActionContext.getContext().getSession()
.put("user" , getUsername());
return SUCCESS;
}
else
{
return ERROR;
}
}
}

不知道是什么问题就是不能解决,导致LoginAction类无法编译,谢谢大家啦
...全文
1118 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
yige635337727 2015-12-03
  • 打赏
  • 举报
回复
提问楼主怎么解决的?该jar包我已经导入进去了啊。还是没法编译
inuyasha1 2014-11-23
  • 打赏
  • 举报
回复
引用 5 楼 magi1201 的回复:
[quote=引用 3 楼 inuyasha1 的回复:] 嗯嗯,就是通过doc编译的,我也把包添加到classpath了,但是还是不行诶,在classpath下添加的路径是“C:\Users\workspace\webDemo\WebContent\WEB-INF\lib”,编译的时候还是一样的提示没有包。
都做java ee 开发了,建议楼主不要使用dos窗口进行开发了。 快使用集成开发环境吧,像eclipse或者MyEclipse,这些集成开发环境智能的多 使用IDE,是开发效率事半功倍,尤其在编译,缺少jar包方面,直接指出缺少哪个jar包,缺少哪个类等错误。[/quote] 嗯嗯,亲。谢谢了。多谢你的提心我已经解决了,万分感谢啊
姜小白- 2014-11-23
  • 打赏
  • 举报
回复
引用 3 楼 inuyasha1 的回复:
嗯嗯,就是通过doc编译的,我也把包添加到classpath了,但是还是不行诶,在classpath下添加的路径是“C:\Users\workspace\webDemo\WebContent\WEB-INF\lib”,编译的时候还是一样的提示没有包。
都做java ee 开发了,建议楼主不要使用dos窗口进行开发了。 快使用集成开发环境吧,像eclipse或者MyEclipse,这些集成开发环境智能的多 使用IDE,是开发效率事半功倍,尤其在编译,缺少jar包方面,直接指出缺少哪个jar包,缺少哪个类等错误。
inuyasha1 2014-11-23
  • 打赏
  • 举报
回复
引用 2 楼 magi1201 的回复:
你是想通过dos窗口去使用javac 编译的吗? 那你将支撑jar放到WEB-INF/lib 下面是不起作用的,需要在编译时候添加classpath 指向你的WEB-INF/lib 然后 去编译 就可以了
请问除了在doc下面编译还可以在哪里编译呢?
inuyasha1 2014-11-23
  • 打赏
  • 举报
回复
引用 2 楼 magi1201 的回复:
你是想通过dos窗口去使用javac 编译的吗? 那你将支撑jar放到WEB-INF/lib 下面是不起作用的,需要在编译时候添加classpath 指向你的WEB-INF/lib 然后 去编译 就可以了
嗯嗯,就是通过doc编译的,我也把包添加到classpath了,但是还是不行诶,在classpath下添加的路径是“C:\Users\workspace\webDemo\WebContent\WEB-INF\lib”,编译的时候还是一样的提示没有包。
姜小白- 2014-11-23
  • 打赏
  • 举报
回复
你是想通过dos窗口去使用javac 编译的吗? 那你将支撑jar放到WEB-INF/lib 下面是不起作用的,需要在编译时候添加classpath 指向你的WEB-INF/lib 然后 去编译 就可以了
inuyasha1 2014-11-23
  • 打赏
  • 举报
回复
不要沉啊,亲们求帮忙啊
struts 2.3.4.1 最新英文版API =========================================================== 概览 程序包 类 使用 树 已过时 索引 帮助 上一个 下一个 框架 无框架 所有类 ----------------------------------------------------------- Struts 2.3.4.1 API 程序包 程序包 说明 ------------------------------------------------------------ com.opensymphony.xwork2 Main XWork interfaces and classes. com.opensymphony.xwork2.config Configuration core classes. com.opensymphony.xwork2.config.entities Configuration entity classes. com.opensymphony.xwork2.config.impl Configuration implementation classes. com.opensymphony.xwork2.config.providers Configuration provider classes. com.opensymphony.xwork2.conversion com.opensymphony.xwork2.conversion.annotations Type conversion annotations. com.opensymphony.xwork2.conversion.impl com.opensymphony.xwork2.conversion.metadata Type conversion meta data classes. com.opensymphony.xwork2.inject Guice (pronounced "juice"). com.opensymphony.xwork2.inject.util Guice util classes. com.opensymphony.xwork2.interceptor Interceptor classes. com.opensymphony.xwork2.interceptor.annotations Interceptor annotations. com.opensymphony.xwork2.mock XWork specific mock classes. com.opensymphony.xwork2.ognl com.opensymphony.xwork2.ognl.accessor com.opensymphony.xwork2.spring Spring ObjectFactory classes. com.opensymphony.xwork2.spring.interceptor Spring specific interceptor classes. com.opensymphony.xwork2.test com.opensymphony.xwork2.util XWork util classes. com.opensymphony.xwork2.util.classloader com.opensymphony.xwork2.util.finder com.opensymphony.xwork2.util.fs com.opensymphony.xwork2.util.location Classes and utilities used to track location information. com.opensymphony.xwork2.util.logging com.opensymphony.xwork2.util.logging.commons com.opensymphony.xwork2.util.logging.jdk com.opensymphony.xwork2.util.profiling Classes to enable profiling of action execution. com.opensymphony.xwork2.util.reflection com.opensymphony.xwork2.validator XWork validation subsystem. com.opensymphony.xwork2.validator.annotations Validator annotations. com.opensymphony.xwork2.validator.metadata Validator meta data classes. com.opensymphony.xwork2.validator.validators XWork default validator classes. org.apache.struts2 org.apache.struts2.components org.apache.struts2.components.template org.apache.struts2.config Classes for Struts configuration and property handling. org.apache.struts2.dispatcher Classes for action dispatching in Struts (the Controller part of MVC). org.apache.struts2.dispatcher.mapper org.apache.struts2.dispatcher.multipart Classes to help dispatch multipart HTTP requests. org.apache.struts2.dispatcher.ng This package contains a reimagining of the traditional Struts filter dispatchers. org.apache.struts2.dispatcher.ng.filter org.apache.struts2.dispatcher.ng.listener org.apache.struts2.dispatcher.ng.servlet org.apache.struts2.impl org.apache.struts2.interceptor org.apache.struts2.interceptor.debugging org.apache.struts2.interceptor.validation org.apache.struts2.servlet.interceptor org.apache.struts2.util org.apache.struts2.views org.apache.struts2.views.annotations org.apache.struts2.views.freemarker org.apache.struts2.views.freemarker.tags org.apache.struts2.views.jsp Struts's JSP tag library. org.apache.struts2.views.jsp.iterator org.apache.struts2.views.jsp.ui org.apache.struts2.views.util Miscellaneous helper classes for all views. org.apache.struts2.views.velocity Classes for views using Velocity. org.apache.struts2.views.velocity.components org.apache.struts2.views.xslt The new xslt view supports an extensible Java XML adapter framework that makes it easy to customize the XML rendering of objects and to incorporate structured XML text and arbitarary DOM fragments into the output. ------------------------------------------------------------ 概览 程序包 类 使用 树 已过时 索引 帮助

67,549

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧