SpringMVC-SSH全注解

时间:2017-03-18 09:11:23
【文件属性】:

文件名称:SpringMVC-SSH全注解

文件大小:13.33MB

文件格式:ZIP

更新时间:2017-03-18 09:11:23

SpringMVC

package com.org.core.entity; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; @Entity public class User { @Id @GeneratedValue private int id; @Column(name = "username") private String username; @Column(name = "password") private String password; public int getId() { return id; } public void setId(int id) { this.id = id; } 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; } } package com.org.core.service.impl; import java.util.List; import javax.annotation.Resource; import org.springframework.stereotype.Service; import com.org.core.dao.UserDao; import com.org.core.entity.User; import com.org.core.service.UserService; /** *@Author:liangjilong *@Date:2014-2-25 *@Version:1.0 *@Description: */ @Service public class UserServiceImpl implements UserService{ @Resource private UserDao userDao; @Override public List getListUsers() { return userDao.getListUsers(); } } package com.org.core.dao.impl; import java.util.List; import javax.annotation.Resource; import org.springframework.orm.hibernate3.HibernateTemplate; import org.springframework.stereotype.Repository; import com.org.core.dao.UserDao; import com.org.core.entity.User; /** *@Author:liangjilong *@Date:2014-2-25 *@Version:1.0 *@Description: */ @Repository public class UserDaoImpl implements UserDao { @Resource private HibernateTemplate hibernateTemplate; @SuppressWarnings("unchecked") public List getListUsers() { String hql="From User"; List lists=hibernateTemplate.find(hql); return lists; } } package com.org.core.action; import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import com.org.core.entity.User; import com.org.core.service.UserService; import com.org.utils.servlet.ServletUtils; /** *@Author:liangjilong *@Date:2014-2-25 *@Version:1.0 *@Description: */ @Controller public class UserController{ @Resource private UserService userService; @RequestMapping(value="/userList1.do") public String geUserList1(HttpServletRequest request ,HttpServletResponse response) throws Exception { List lists=userService.getListUsers(); if(lists!=null){ //request.setAttribute("userList", lists); ServletUtils.setRequestValue("userList", lists); } return "/user/userList";//user文件下的userList.jsp } @RequestMapping(value="/userList2.do") public ModelAndView geUserList2(HttpServletRequest request ,HttpServletResponse response) throws Exception { List lists=userService.getListUsers(); if(lists!=null){ //request.setAttribute("userList", lists); ServletUtils.setRequestValue("userList", lists); } return new ModelAndView("/user/userList"); } } classpath:jdbc.properties com.org.core.entity ${hibernate.dialect} true


【文件预览】:
ISSH
----.myumldata(66B)
----.settings()
--------org.eclipse.wst.jsdt.ui.superType.name(6B)
--------org.eclipse.wst.common.project.facet.core.xml(412B)
--------org.eclipse.wst.common.component(463B)
--------org.eclipse.wst.jsdt.ui.superType.container(49B)
--------.jsdtscope(522B)
--------org.eclipse.jdt.core.prefs(598B)
----src()
--------jdbc.properties(269B)
--------log4j.properties(290B)
--------com()
--------struts.properties(20B)
----.project(1KB)
----WebRoot()
--------META-INF()
--------WEB-INF()
--------js()
--------index.jsp(842B)
--------jsp()
----.classpath(1KB)
----build()
--------classes()

网友评论

  • 谢谢分享,不过导入了工程,有错误,不知道什么原因,丢起来
  • 感谢分享,不错的实例!