spring不能自动实例化beanSpringBean实例
解决方案 »
- The specified JRE installation does not exist
- session 从tomcat开始,经struts2,过hibernate,它的变化是什么?
- ssh配置测试,找不到namespace action
- 关于jboss和Myeclipse8.5的EJB访问方式
- 急!高分请教!jsp如何用POI读word内容?
- 无法连接数据库
- weblogic9 下事务超时怎么解决??
- Quartz异常怎么处理
- 用了<jsp:include></jsp:include>标签时发生异常,各位请帮忙看看!
- 麻烦大家给介绍介绍几本J2EE的入门书呗
- 用hibernate框架通过id查数据中的对象一直为空
- hibernatete的配置问题
<bean id="userDao" class="com.blog.dao.UserDaoImpl" />
<!-- 配置业务逻辑组件 -->
<bean id="userService" class="com.blog.service.UserServiceImpl">
<property name="userDao">
<ref bean="userDao"/>
</property>
</bean>
<!-- 配置RegisterAction -->
<bean id="register" class="com.blog.action.Register" scope="prototype">
<property name="userService">
<ref bean="userService"/>
</property>
</bean>
<!-- 配置LoginAction -->
<bean id="login" class="com.blog.action.Login" scope="prototype">
<property name="userService">
<ref bean="userService"/>
</property>
</bean>applicationContent.xml配置如上
运行报错
<result name="input">/login.jsp</result>
<result name="success">/success.jsp</result>
</action>
<action name="register" class="com.blog.action.Register">
<result name="input">/register.jsp</result>
<result name="success">/success.jsp</result>
<result name="error">/register_error.jsp</result>
</action>
private UserService userService;
private String username;
private String password; public UserService getUserService() {
return userService;
} public void setUserService(UserService userService) {
this.userService = userService;
} public String execute() throws Exception {
User user = new User();
user.setUsername(username);
user.setPassword(password);
//没有new一个对象时,报Exception occurred during processing request: null
//userService = new UserServiceImpl();
HttpServletRequest request = ServletActionContext.getRequest();
//System.out.println(user.getUsername());
if(userService.loginUser(user)){
Map<String, Object> session = ActionContext.getContext().getSession();
session.put("username", username);
request.setAttribute("info", username+"登录成功!");
System.out.println("hello!");
return SUCCESS;
}
else
return INPUT;
}
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;
}
}
43行?重新运行后的错误行是哪个?哦,我把注释删了,报错行if(userService.loginUser(user))
<bean id="login" class="com.blog.action.Login" scope="prototype">
<property name="userService">
<ref bean="userService"/>
</property>
</bean>中的id值"login".
<!-- 配置LoginAction -->
<bean id="login" class="com.blog.action.Login" scope="prototype">
<property name="userService">
<ref bean="userService"/>
</property>
</bean>
解决办法:改为<action name="login" class="login">应该就可以了!