Struts2框架中,Action类若没有放在一个包里,就会报空指针,为什么

图片说明

2个回答

已经很明显了呀,就是因为你的class的路径写错了呀,没有加包名不意味着就是直接写类名呀,还是要将默认包名写上去的。。。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
ServletActionContext.getRequest()为什么会报空指针?
做一个项目的时候,用到了HttpSessionBindingListener监听session失效rn当运行valueBound的时候可以正常获取request,而当session失效运行valueUnbound的时候,获取request就会报空指针错误rn代码如下:rn[code=Java]public class SessionListener implements HttpSessionBindingListenerrn private User userObject;rn public SessionListener(User userObject) rn // TODO Auto-generated constructor stubrn this.userObject = userObject;rn rn //用户存sessionrn public void valueBound(HttpSessionBindingEvent event) rn // TODO Auto-generated method stubrn HttpSession session = event.getSession();rn session.setAttribute("userInfo", userObject);rn DateFormat df = DateFormat.getDateTimeInstance();rn System.out.println(df.format(new Date())+"绑定数据源:"+userObject.getUserName()+":"+session.getId()+":"+session.getCreationTime());rn try rn //这里就不会报错..奇怪rn System.out.println("测试一下获取request");rn HttpServletRequest request = ServletActionContext.getRequest();rn HttpSession session1 = request.getSession();rn catch (Exception e) rn // TODO: handle exceptionrn e.printStackTrace();rn rn rn rn // 用户SESSION失效,重新封装用户信息rn public void valueUnbound(HttpSessionBindingEvent event) rn //这里就会报错..rn HttpServletRequest request = ServletActionContext.getRequest();rn HttpSession session = request.getSession();rn rn rn public static String getCookieValue(Cookie[] cookies,String cookieName,String defaultValue) rn for(int i=0; i
为什么会报空指针的错误!??????
action中的代码: public ActionForward execute(ActionMapping mapping, ActionForm form,rn HttpServletRequest request, HttpServletResponse response) rn ActionForward result=null;rn List listNavigation=null;rn List> list=null;rn List listBanner=banner.getAll("");rn for(Banners bb:listBanner)rn listNavigation=navigation.getListPagern (0, 5, "from Navigations where bid="+bb.getId());rn System.out.println("栏目"+bb.getId());rn list.add(listNavigation);rn rn for(Navigations nn:listNavigation)rn System.out.println("nname="+nn.getNaname());rn rn rn rn rn request.setAttribute("listBanner", listBanner);rn request.setAttribute("list",list);rn rn result=mapping.getInputForward();rn return result;rn我用debug跟踪了一下 发现到了list.add(listNavigation);这句就出错 这是为什么???rn还有我在jsp页面用这样一段代码 来输出 你们看看对不对rn rn rn rn rn rn
类必须放在包里
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/E:/study/maven/repository/org/springframework/boot/spring-boot-autoconfigure/1.
为什么会报空指针?好奇怪!
public final Drawable getChild(int index) rn final Drawable result = mDrawables[index];rn if (result != null) rn return result;rn rnrn // Prepare future drawable if necessary.rn if (mDrawableFutures != null) rn final int keyIndex = mDrawableFutures.indexOfKey(index);rn if (keyIndex >= 0) rn final ConstantState cs = mDrawableFutures.valueAt(keyIndex);rn final Drawable prepared = prepareDrawable(cs.newDrawable(mSourceRes));rn mDrawables[index] = prepared;rn mDrawableFutures.removeAt(keyIndex);//在Monkey测试时mDrawableFutures报了空指针错误,why?!rn if (mDrawableFutures.size() == 0) rn mDrawableFutures = null;rn rn return prepared;rn rn rnrn return null;rn rn上面是出问题的方法,有文字注释的是报空指针的地方。求大神们解释一下为什么是我写注释的那一行报了错?
为什么log会报空指针异常错误?
我在编写添加背景音乐的程序时,参考了这里的代码http://apps.hi.baidu.com/share/detail/18496230rnrn我的工程中有两个类,一个是music类,继承activity,另一个是musicServer类,集成service。music类如下:rn[code=Java]package mx.music;rnrnimport android.app.Activity;rnimport android.content.Intent;rnimport android.os.Bundle;rnimport android.view.View;rnimport android.view.View.OnClickListener;rnimport android.widget.Button;rnrnpublic class music extends Activity rn /** Called when the activity is first created. */rn rn [color=#FF0000]private Intent intent = new Intent("mx.music.MUSIC");[/color]rn private Button startButton;rn private Button stopButton;rn @Overridern public void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState);rn setContentView(R.layout.main);rn startButton = (Button) findViewById(R.id.startButton);rn stopButton = (Button) findViewById(R.id.stopButton);rn startButton.setOnClickListener(new startListener());rn stopButton.setOnClickListener(new stopListener());rn rn rn rn rn class startListener implements OnClickListenerrnrn public void onClick(View v) rn // TODO Auto-generated method stubrn [color=#FF0000] startService(intent);[/color]rn rn rn rn rn class stopListener implements OnClickListenerrnrn public void onClick(View v) rn // TODO Auto-generated method stubrn [color=#FF0000]stopService(intent);[/color]rn rn rn rn rn @Overridern protected void onPause() rn // TODO Auto-generated method stubrn super.onPause();rn rn rn rn rn rn rnrn[/code]rnrnmusicserver类如下:[code=Java]rnpackage mx.music;rnrnimport android.app.Service;rnimport android.content.Intent;rnimport android.media.MediaPlayer;rnimport android.os.IBinder;rnrnpublic class musicServer extends Servicernrn private MediaPlayer mp;rn @Overridern public IBinder onBind(Intent arg0) rn // TODO Auto-generated method stubrn return null;rn rn @Overridern public void onStart(Intent intent, int startId) rn // TODO Auto-generated method stubrn super.onStart(intent, startId);rn if(mp==null)rn mp=MediaPlayer.create(this, R.raw.mmp);rn [color=#FF0000]mp.start();[/color]/*显示这里空指针异常,但是我在上句都已经定义了啊,并且在raw中存在mmp的MP3文件*/rn rn rn @Overridern public void onDestroy() rn // TODO Auto-generated method stubrn super.onDestroy();rn mp.stop();rn rn rn rnrnrn[/code]
框架中为什么会报拒绝访问?
我有一个页面a.jsp,它的主要功能是将其中FORM的内容提交到另一个SERVLET,而这个SERVLET的作用是生成文件,并产生一个application/octet-stream类型的(response的)OutputStream以让用户下载该文件,所以a.jsp不会刷新.rn现在的问题是,rn而如果a.jsp在一个frame中,则提交一次FORM后(能正确得到下载的文件),就无法进行任何其他操作.都会报JS错误"拒绝访问".rn我进行了很多次其他试验,结果如下:rn1.a.jsp如果不在frame中,则提交一次FORM后(即下载了一次文件),a.jsp还可以进行其他操作.rn2.将a.jsp更名为a.html(即去掉了一些BEAN的引用和使用),问题依旧.rn3.以新建窗口(window.open())方式提交,则问题不存在.rn4.将a.jsp的提交部分提炼出来(因为a.jsp中包含了一个xml数据岛外部文件的载入,和一些比较复杂的JS代码)作为b.jsp,并在框架中用b.jsp代替a.jsp,则问题不存在.rn5.对以上试验都实现了GET和POST方式.rn有谁知道为什么会出现这样的情况,谢谢!
为什么把类放在一个包里就能运行,而放在根目录下就不行?
我在运行jsp的时候遇到这样一个问题:rn我自己编了一个bean文件放在了classes根目录下,结果发现找不到该类,但是我把那个bean放在一个包里就能正常运行了。不知为什么?rnrn如:把fileReader放在一个包里,在用javaBean时加上包名.如:rnrn rnrn
Struts2中Action类的创建
直接创建普通java类,不继承父类也不实现接口 实现一个Action接口,提供Action规范以及Action接口预置的字符串,可以作为返回结果使用 public class Action implements com.opensymphony.xwork2.Action { @Override public String execute() throws Excepti...
struts2中action类的创建
1.通过java中面向对象的原理,向上抽取建立baseAction public class BaseAction extends ActionSupport implements ModelDriven {   //通过java中面向对象的原理,向上抽取建立baseAction protected T model; public BaseAction(){ Parame
struts2例子中的action类
很经典的struts2开发实例,其中的action类的写法可以教你很清楚的了解具体的调用过程回给你开发带来很大的帮助
Struts2框架Action类的三种写法
Action类的三种写法     *   Action类就是一个POJO类             POJO(Plain Ordinary Java Object)简单的Java对象。理解记:没有继承、也没有实现接口,就是POJO类。如:             *   Action类可以实现Action接口         *   在Action接口中定义了5个常量,常量的值对应的是5个逻辑视图...
莫名其妙的空指针,struts2框架报错
264916 ERROR [2013-06-12 22:47:58] com.opensymphony.xwork2.util.logging.commons.CommonsLogger.error(CommonsLogger.java:38) Exception occurred during processing request: nullrnjava.lang.NullPointerExceptionrn at com.shehong.info.action.InformationAction.add(InformationAction.java:70)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Struts2框架之动态方法调用action类
首先需要先开启动态方法的开关 访问路径为: "http://localhost:8080/struts2_05/hello/test1!hello1", 注意为"test1"后面追加的是"!"+"方法名" 配置文件: <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLI
ssh action类报空指针
rnrnrnrn rn rn rn rn rn rn rn rn rnrn rn rn rn rn rn rn org.hibernate.dialect.MySQLDialectrn rn rn rn rn rn com/jinshuo/entity/Admin.hbm.xmlrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrnaction类执行的时候报空指针。rnrnpackage com.jinshuo.action;rnrnimport javax.servlet.http.HttpSession;rnrnimport org.apache.struts2.ServletActionContext;rnimport org.springframework.context.ApplicationContext;rnimport org.springframework.context.support.ClassPathXmlApplicationContext;rnrnimport com.jinshuo.entity.Admin;rnimport com.jinshuo.service.impl.AdminServiceImpl;rnimport com.jinshuo.service.inter.AdminService;rnimport com.opensymphony.xwork2.ActionSupport;rnrnpublic class AdminAction extends ActionSupportrn private AdminService adminService;rnrn public AdminService getAdminService() rn return adminService;rn rnrn public void setAdminService(AdminService adminService) rn this.adminService = adminService;rn rn public Admin admin;rnrn public Admin getAdmin() rn return admin;rn rnrn public void setAdmin(Admin admin) rn this.admin = admin;rn rn public String login() rn System.out.println("00");rn System.out.println(admin.getName());rn System.out.println(admin.getPassword());rn rn /* ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");rn System.out.println("0");rn AdminServiceImpl adminServiceImpl = (AdminServiceImpl) ctx.getBean("adminservice");*/rn System.out.println("save-begin");rn [color=#FF0000][/color]adminService.addAdmin(admin);//这里报空指针。。rn System.out.println("save-end");rn rn Admin adm = adminService.login(admin);rn System.out.println("02");rn rn HttpSession session=ServletActionContext.getRequest().getSession();rn System.out.println("03");rn if (adm != null)rn session.setAttribute("admin_info", adm);rn return "loginsuccess";rn rn return INPUT; rn rn public String execute()rn System.out.println("123");rn return null;rn rnrnrn
listview下滑会报空指针
package jp.co.tre.pacer.shelfcheck;rnrnimport java.util.ArrayList;rnimport java.util.HashMap;rnimport java.util.List;rnrnimport jp.co.tre.pacer.shelfcheck.R;rnimport jp.co.trejapan.pacer.android.activity.PacerMainActivity;rnimport jp.co.trejapan.pacer.android.ui.FooterAdapter;rnimport android.content.Context;rnimport android.content.Intent;rnimport android.os.Bundle;rnimport android.view.LayoutInflater;rnimport android.view.View;rnimport android.view.ViewGroup;rnimport android.view.View.OnClickListener;rnimport android.widget.AdapterView;rnimport android.widget.AdapterView.OnItemClickListener;rnimport android.widget.ListView;rnimport android.widget.TextView;rnrnpublic class NewShelfReferActivity extends PacerMainActivity rn private List> list = new ArrayList>(); // 声明列表容器rn private HashMap item1 = new HashMap();rn private ListAdapter dataAdapter;rn private ListView listView;rn private TextView title;rn private int selectedPosition = 0;rnrn @Overridern public void onCreate(Bundle savedInstanceState) rnrn super.onCreate(savedInstanceState);rn setContentView(R.layout.shelf_refer);rn titleLayout.setTitleText(getString(R.string.title_name));rn pageinit();rn listInit();rn setFooterStyle();rn rnrn public void pageinit() rn listView = (ListView) findViewById(R.id.mylist_refer);rn title = (TextView) findViewById(R.id.title1);rn Intent intent = getIntent();rn String name = intent.getStringExtra("name");rn title.setText(name);rn for (int i = 0; i < 10; i++) rn HashMap skt = new HashMap();rn skt.put("name", "lll" + i);rn skt.put("id", "8101" + i);rn list.add(skt);rn rn rnrn public void listInit() rnrn dataAdapter = new ListAdapter(NewShelfReferActivity.this, list,rn R.layout.list_shelf_refer, new String[] "name", "id" ,rn new int[] R.id.shelfname, R.id.shelfno ) rn class ViewHolder rn TextView sname;rn TextView sno;rn rnrn public View getView(final int position, View convertView,rn ViewGroup parent) rn ViewHolder holder = null;rn View view = convertView;rn if (view == null) rn LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);rn view = inflater.inflate(R.layout.list_shelf_refer, null,rn false);rn holder = new ViewHolder();rn holder.sname = (TextView) view.findViewById(R.id.shelfname);rn holder.sno = (TextView) view.findViewById(R.id.shelfno);rnrn else rn holder = (ViewHolder) view.getTag();rn rn HashMap record = list.get(position);rn holder.sname.setText(record.get("name"));rn holder.sno.setText(record.get("id"));rn dataAdapter.notifyDataSetChanged();rn return view;rn rnrn ;rnrn listView.setAdapter(dataAdapter);rn listView.setOnItemClickListener(new OnItemClickListener() rnrn @Overridern public void onItemClick(AdapterView arg0, View arg1, int arg2,rn long arg3) rn selectedPosition = arg2;rn item1 = list.get(selectedPosition);rn Intent intent = new Intent();rn intent.setClass(NewShelfReferActivity.this,rn NewShelfLoginActivity.class);rn intent.putExtra("name", item1.get("name"));rn intent.putExtra("id", item1.get("id"));rn startActivity(intent);rnrn rn );rn rnrn // btn定义rn private void setFooterStyle() rn String[] btnText = new String[4];rn btnText[0] = getString(R.string.back);rn btnText[1] = "";rn btnText[2] = "";rn btnText[3] = "";rnrn OnClickListener[] listenner = new OnClickListener[4];rn listenner[0] = new OnClickListener() rnrn @Overridern public void onClick(View v) rn finish();rn System.exit(0);rn rn ;rnrn listenner[1] = new OnClickListener() rnrn @Overridern public void onClick(View v) rn rn ;rn listenner[2] = null;rn listenner[3] = new OnClickListener() rnrn @Overridern public void onClick(View arg0) rn // TODO Auto-generated method stubrnrn rnrn ;rn FooterAdapter adapter = new FooterAdapter(this, btnText, listenner);rn footer.setAdapter(adapter);[code=java][/code]rnrn rnrn
明明有数据为什么会报空指针
[img=https://img-bbs.csdn.net/upload/201610/11/1476177616_50042.png][/img]rn非计算机系新手求指导
我的这段java代码为什么会报空指针?
这是学生类package com.lianxi.com;public class Student{private int on;   //学生编号private String name;   //学生名字private int age;   //年龄private double java;  //java成绩private double C;   //c语言成绩private double HTM...
关于Struts2的Action类
我想知道,如果我什么Action类都没写(src目录下),但是我在Struts.xml文件中却有配置action跳转rn例如我写了rn rn rn /aa.jsprn rn rn rnrn但是我没有创建d这个类。请问可以访问到 aa.jsp(已创建)吗?我看过一些视频,是可以的。。可是没说为什么?我想知道是默认值什么的吗?
ssh框架中的struts2中的action出问题
页面显示---There is no action namespace / and action ..... 上面的action找到地址了下面的却出异常。。。rnrn /MyOffice.files/RoleMgr.jsprn /MyOffice.files/RoleMgr.jsprn role!roleAll.actionrn /MyOffice.files/RoleMgr.jsprn role!roleAll.actionrn role!roleAll.actionrn rn-------》》》异常rn [color=#FF0000]rn /MyOffice.files/LoginLog.jsprn /MyOffice.files/LoginLog.jsprn [/color] rn rn---------------------------------rnrn rn rnrn rn rn rnrn rn rn rnrn rn rn rn rn [color=#FF0000]rn rn rn [/color]
spring 管理 struts2 action总是报空指针
用spring.jar来管理STRUTS2的ACTION总是报空指镇,很郁闷来着.rnrn[code="java"][/code]rnapplicationContext.xml:rnrnrnrnrnrn rn rn rn /WEB-INF/config/jdbc.propertiesrn rn rn rn rn $jdbc.driverrn rn rn $jdbc.urlrn rn rn $jdbc.usernamern rn rn $jdbc.passwordrn rn rn rn rn rn /WEB-INF/config/SqlMapConfig.xmlrn rn rn rn rn rnrn rn rn rn rn rn rnrnrnrn rn rn rn rn rn rnrn rn rn rnrn rn rn rnrnrnrnrnstruts-user.xml:rnrnrnrnrn rn rn rn ../main.jsprn rn rnrn上面,注入就失几,郁闷的了rnweb.xml:rnrn rn org.springframework.web.context.ContextLoaderListenerrn rn rnrn rn contextConfigLocationrn rn /WEB-INF/config/applicationContext.xmlrn rn rnrn rn index.jsprn rn....rnrnUserAction:rnprivate UserService userServiceImpl;rnrn private List userList = new LinkedList();rnrn private String resultInfo;rnrn public UserAction()rn rn rn rn rn rn rn public String getAllUsers()rn rn this.userList = userServiceImpl.getAllUsers();rn return SUCCESS;rn rnrnSET方法中打印都能出来,可到上面代码总是报错,郁闷n[b]问题补充:[/b]njava.lang.NullPointerExceptionrn com.emsg.wcy.action.UserAction.getAllUsers(UserAction.java:35)rn sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn java.lang.reflect.Method.invoke(Method.java:597)rn com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)rn com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)rn com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)rn com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)rn org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)rn com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)rn com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)rn com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)rn com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)rn org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)rn org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)rn org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)rnrn
为什么JBuilder中的servlet包里没有javax.servlet.jsp.tagext.*
我在用JBuilder9写jsp标签rnimport javax.servlet.jsp.tagext.*时,提示没有这个包rn我查看了一下,JBuilder 中 javax.servlet.jsp下只有一个 ”jst1“rn这是为什么?rn难道JBuilder中tomcat自带的servlet包是不齐全的吗?rn我已经将jakarta-tomcat-4.1.24-LE-jdk1.4\common\lib\servlet.jar加到classpath中了! rnrn还望各位指点一二!rn
JSP自定义的类必须放在包里吗?
比如自定义一个类BookrnBook.java文件直接放在WEB-INF\classes中,编译成功,产生了Book.class文件rn写一个页面引用这个类:rn<%@ import="Book" %>rn报错:rnAn error occurred at line: [15] in the generated java file: rnThe import Book cannot be resolvedrn查看编译好的servlet文件:rnimport Book;rnrn就是这一行报的错。rnrn问题:rn自定义的类必须放在包里吗?rnrn
为什么会报没有入口点
我用的win7 32位 masm 6.11rnrn代码是rnrnassume cs:abcrnabc segmentrnstart:rn mov ax,2rn add ax,axrn add ax,axrn mov ax,4c00rn int 21rnabc endsrnend startrn
struts2框架中Action的三种编写方式
一、Action的三种编写方式:1、实现Action类2、继承ActionSupport接口3、自己定义pojo类(没有继承类,也没有实现任何接口)、1、实现Action类*Action接口中包含5个常量和一个execute方法 *5个常量分别是: *1、 public static final String SUCCESS = &quot;success&quot;;表示运行成功时返回的逻辑视图 *2、 publi...
使用Struts2框架找不到action
项目结构rn[img=https://img-bbs.csdn.net/upload/201606/01/1464787444_568865.png][/img]rnjar包rn[img=https://img-bbs.csdn.net/upload/201606/01/1464787487_325238.png][/img]rnweb.xmlrn[img=https://img-bbs.csdn.net/upload/201606/01/1464787546_555232.png][/img]rnstruts.xmlrn[img=https://img-bbs.csdn.net/upload/201606/01/1464787607_355274.png][/img]rnindex.jsprn[img=https://img-bbs.csdn.net/upload/201606/01/1464787667_615115.png][/img]rninput.jsprn[img=https://img-bbs.csdn.net/upload/201606/01/1464787683_445048.png][/img]rn出现的错误信息rn[img=https://img-bbs.csdn.net/upload/201606/01/1464787745_174487.png][/img]
Struts2的ValueStack中没有Action属性值(成员)
在Struts2里写了一个Action: public class UserAction extends ActionSupport implements ModelDriven { private UserMgr um; private UserInfo userInfo = new UserInfo(); private List users; public String exe
struts2 -- 一个action类实现多个方法
SSH之action中的多个方法的调用方法public String logon(){ return &quot;success&quot;; } public String register(){ return&quot;success&quot;; } 有三种方式可以将页面提交和action的方法对应。     (一)动态方法调用,配置文件不变,一个action类对应配置文件中一个action标...
SSH框架中在Action中调用DAO报空指针
在使用MyEclipse10中进行了SSH(Struts2)框架的整合,使用了MyEclipse10中Hibernate自动生成DAO的方法生成了相关配置和DAO,我也在Spring配置文件中配置了相关使用的Action类,然而当我在Action中使用DAO时却报空指针异常,但是当我使用了一个Service类来使用这个DAO却一切正常(配置文件配置正确)。求高人指点!!
SSH框架中,是不是一个form 就必须有一个action
SSH框架中,是不是一个form 就必须有一个action呢?rn那其他请求,比如链接到其他page是否需要action?
Struts2中Action类的三种定义方式
1.重写execute方法 package com.zchen.struts.action; public class RegisterAction { public String execute() { return null; } }   2.继承Action接口 package com.zchen.struts.action...
struts2中Action类的书写方式
方式一://方式1: 创建一个类.可以是POJO //POJO:不用继承任何父类.也不需要实现任何接口. //使struts2框架的代码侵入性更低. public class Demo3Action { }方式二://方式2: 实现一个接口Action // 里面有execute方法,提供action方法的规范. // Action接口预置了一些字符串.可以在返回结果时使用.为了方便 publi...
struts2 Action类中构造方法问题
定义了一个action类:rnpublic class Login1 extends ActionSupportrn rn private Map request;rn private Map session;rn private Map application; rn rn public Login1()rn ActionContext ac=ActionContext.getContext();rn request=(Map)ac.get("request");rn session=ac.getSession();rn application=ac.getApplication();rn rnrn public String execute()rn rn request.put("r1", "r1");rn session.put("s1", "s1");rn application.put("a1", "a1");rn rn return SUCCESS;rn rnrnrn在jsp页面做了一个form表单,点击提交就会调用到这个action类,可是每次都会报出request为空的错误,把构造方法中的内容加到execute方法中又不会报出错误,求高手指教原因
struts2中action类return的问题
[b]action类:[/b]rn [color=#FF6600]return ProcessLogStatisticsData.success(Slist);[/color]rn[b]ProcessLogStatisticsData类[/b]:rn [color=#FF6600]return CommonResult.success(new ProcessLogStatisticsData(list));[/color]rn[b]CommonResult类:[/b]rn[color=#FF6600] public static final CommonResult success(IData data)rn return new CommonResult(Code.SUCCESS, "success", data);rn [/color]rnrn最后返回一个CommonResult对象,对象里的数据都有getter方法。rn rn[b]struts.xml:[/b]rn [color=#FF6600]rn resultrn falsern truern truern UTF-8rn text/plain;charset=UTF-8rn [/color]rn然后所有的action返回配置都是这样的,客户端是安卓的。rnrn我想问的第一问题:rn return的数据是怎么返回到客户端的?rnrn我想问的第二问题:rn xml的配置name="root"的值为什么是result,action里明明没有这个数据。rnrnrnrnrn
struts2、Spring3、hibernate,运行时Action中提示service空指针
Action代码如下:rn[code=Java]package com.bbs.action;rnrnimport com.bbs.bean.User;rnimport com.bbs.service.UserService;rnrnpublic class LoginAction rn private User user;rn private String userName;rn private String pwd;rn private UserService userService;rnrn public String getUserName() rn return userName;rn rnrn public void setUserName(String userName) rn this.userName = userName;rn rnrn public String getPwd() rn return pwd;rn rnrn public void setPwd(String pwd) rn this.pwd = pwd;rn rnrn public User getUser() rn return user;rn rnrn public void setUser(User user) rn this.user = user;rn rnrn public String Login() rn String rs = null;rn try rn User user = userService.findUser(userName);rn System.out.println(user.getName() + user.getPasw());rn if (user != null && user.getPasw().equals(pwd)) rn rs = "success";rn else rn rs = "error";rn rn catch (Exception e) rn e.printStackTrace();rn rn return rs;rn rnrn public UserService getUserService() rn return userService;rn rnrn public void setUserService(UserService userService) rn this.userService = userService;rn rn rnrn[/code]rnUserServiceImpl代码:rn[code=Java]package com.bbs.service.impl;rnrnimport com.bbs.bean.User;rnimport com.bbs.dao.UserDao;rnimport com.bbs.service.UserService;rnrnpublic class UserServiceImpl implements UserServicern rn private UserDao userDao;rnrn @Overridern public User findUser(String userName) rn return userDao.findUser(userName);rn rnrn public UserDao getUserDao() rn return userDao;rn rnrn public void setUserDao(UserDao userDao) rn this.userDao = userDao;rn rnrnrn[/code]rnstruts.xml代码:rn[code=XML] rn rn rn rn rn /index.jsp rn rn rn /WEB-INF/jsp/login.jsp rn rn rn /index.jsprn /WEB-INF/jsp/error.jsp rn rn rnrn[/code]rnapplicationContext.xml代码:rn[code=XML]rnrnrn rn rn rn rn rn rn rn rn rn rn rn rn truern org.hibernate.dialect.MySQLDialectrn rn rn rn rn classpath:com/bbs/bean/User.hbm.xmlrn rn rn rnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrnrn[/code]rn
Action类ActionContext.getContext().getSession()报空指针
rn其他的Action类用ActionContext.getContext().getSession()都没错,为什么在这个Action类里总报空指针?一去掉这句就正常。rnrnrn严重: Servlet.service() for servlet jsp threw exceptionrnjava.lang.NullPointerExceptionrn at com.accp.oa.actions.TreeAction$3.nodeSelected(TreeAction.java:94)rn at com.jenkov.prizetags.tree.impl.Tree.notifySelectListeners(Tree.java:668)rn at com.jenkov.prizetags.tree.impl.Tree.select(Tree.java:340)rn at com.jenkov.prizetags.tree.impl.Tree.select(Tree.java:351)rn at com.jenkov.prizetags.tree.impl.TreeUpdater.selectUnselectNodes(TreeUpdater.java:280)rn at com.jenkov.prizetags.tree.impl.TreeUpdater.update(TreeUpdater.java:122)rn at com.jenkov.prizetags.tree.impl.TreeTag.doStartTag(TreeTag.java:242)rnrnrn这个Action报错:public class TreeAction extends ActionSupport implements java.io.Serializable rnrnrn[img]http://dl.iteye.com/upload/attachment/578092/ea3f3109-f090-341c-931f-d66bb4cbe6fa.png[/img]rn
【Struts2】【Action类】【值栈=Context+Root】
值栈每一次请求都会创建一个值栈对象,用于封装请求的所有数据. 值栈分为两个部分Context+rootJSP中查看值栈 <%@taglib prefix="s" uri="/struts-tags"%> <s:debug/>Action类中获取值栈 3个方式(了解)//通过req获取值栈 HttpServletRequest req= ServletActionContext.g
Struts2三种action类的写法
1.普通的方式 package com.it.struts2; public class ActionStruts1 { public String execute() { System.out.println("普通的action方式"); return "struts"; } } &lt;action name="hello" class="com.it.struts2...
Struts2 Action类的三种写法
1 Action类是POJO的类(POJO-----简单java对象类) 建立Action类 2Action类去实现Action接口 3 Action类去继承ActionSupport类 写好Action类之后要写配置文件,并在struts.xml中引入配置文件 编写配置文件 ...
Struts2默认Action处理类
如果配置Action没有指定class属性,系统自动使用ActionSupport类处理
struts2 一个action 转发到 另一个 action 在类内部转发
struts2 action 转发到 action 不通过*rn如何转发? rnrn原因:必须用一个action 根据参数url=*; 转发到相应action, 而第一次请求在session内保存了登录信息状态rnrnrequest.getRequestDispatcher("*.action").forward(request,response);rn不能 转发 *.actionrn希望各位 高高手 帮帮我 rnrn可以通过先请求 一个jsp页面 ,返回给客户端一个页面(包括action-url) , 客户端再请求目标actionrn这样为次级解决方案
相关热词 c++和c#哪个就业率高 c# 批量动态创建控件 c# 模块和程序集的区别 c# gmap 截图 c# 验证码图片生成类 c# 再次尝试 连接失败 c#开发编写规范 c# 压缩图片好麻烦 c#计算数组中的平均值 c#获取路由参数