ssh2 异常 看结果访问:http://111.193.161.237:8080/demo2/
在线测试,到今天六点半前是可以看到的http://111.193.161.237:8080/demo2/
spring相当配置如下
<bean id="userManager" class="com.jeff.service.UserManagerImpl">
<property name="userDao" ref="userDao"></property>
</bean>
<bean id="userAction" class="com.jeff.action.UserAction">
<property name="userManager" ref="userManager"></property>
</bean>
================================================================
对应的action如下
public class UserAction extends ActionSupport{
private String username;
private UserManager userManager;
public void setUserManager(UserManager userManager) {
this.userManager = userManager;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String execute() {
System.out.println(this.username);//布属好后可以执行到此步 也能得到参数
Users u = this.userManager.findUserByName(username);//debug测试结果 userManager 为 null;
System.out.println("================");
if (u != null) {
return "success";
} else {
return "error";
}
}
public static void main(String[] args) {//main方法进行测试
ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml","spring-users.xml"});
UserManager um = (UserManager) ctx.getBean("userManager");
// List<Users> list = um.findAllUsers();
// for(Users user:list){
// System.out.println(user.getName()+"===="+user.getEmail());
// }
System.out.println(um.findUserByName("lidong"));
// Users u = new Users();
// u.setName("peingdaiyi");
// u.setAge(25);
// u.setEmail("peng@);
// um.addUser(u);
// um.deleteById(new Integer("1"));
}
}
此处是正常的可以得到结果(main方法测试结果)
Hibernate:
select
users0_.id as id0_,
users0_.name as name0_,
users0_.age as age0_,
users0_.email as email0_
from
users users0_
where
users0_.name=?
com.jeff.domain.Users@1552b76
====================================================
以下为IE中提交查询显示异常
java.lang.NullPointerException
com.jeff.action.UserAction.execute(UserAction.java:31)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:446)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:285)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
这种问题怎么解决
tomcat现在用的5.5 网上说tomcat版本的问题 我换过6.0 可是启动进就有异常,虽然可以启动得开。 提交后还是这问题!
[ 本帖最后由 JeffLi 于 2013-1-15 16:29 编辑 ]