解决方案 »
- resin下载格式问题
- SSH事务处理错误,求解
- FTP服务器到另一台FTP服务器的数据传输
- JSF框架下的的dataTable表,点击当前行,当前行的背景颜色变为黄色?
- 如何定位一个图片?
- 在第一行输入后,点击"新增计划项"按钮,表格自动添加一空行(和现有行一样,具有各个文本框和选择框等)
- 几个一个电子商务网站的问题
- 如何在java中动态创建一张表??
- class.getClassLoader().getResource()方法是不是不能获取上级目录?
- 一个关于用户权限的问题,请各位大侠多多帮忙!!!
- Spring 启动报错 Injection of autowired dependencies failed 求大神帮忙 !
- hibernate出现 Could not retrieve transation read-only status server提示
struts.xml中package的配置关于UserAction的
UserService 有注入到 action层中吗?
struts也是用注释做的UserAction.javapackage com.icss.ssh.action;import javax.annotation.Resource;import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;import com.icss.ssh.service.UserService;
import com.opensymphony.xwork2.ActionSupport;
@Component("userAction")
@Scope("prototype")
public class UserAction extends ActionSupport{
@Resource(name="userService")
private UserService userService;
private String username;
private String password;
@Action(value="register",
results={
@Result(name="success",location="success.jsp")
}
)
public String register(){
userService.register(username, password);
return "success";
}
public UserService getUserService() {
return userService;
} public void setUserService(UserService userService) {
this.userService = userService;
}
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;
}
}
我用注释@component("userService"),在userAction中用@resource了
这个无所谓@component可以代替@controller,@Repository,@service
我不用struts的xml配置文件了,我用的是注解
能在说具体一点吗?????在实现类里加了啊,在action中也加了,你说的没看到是哪个地方没看到呢??
这个你已经写了getter和setter方法了。注解最好还是写在setter方法上。我没在写注解的时候加过name属性。你可以试一下把name属性移掉,并把注解写在setter上面试试
现在公司如果不是遗留项目的话,都用annotation了,不用xml
一般都会忽略的
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQL5Dialect
</prop>
我一眼也不能揪出来的