onsir 0 Light Poster

I made application web using hibernate + spring + velocity and
IDE Netbeans 6.8 + Glassfish

this my files

applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                           http://www.springframework.org/schema/aop
                           http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
                           http://www.springframework.org/schema/tx
                           http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
                           http://www.springframework.org/schema/context
                           http://www.springframework.org/schema/context/spring-context-2.5.xsd
                           http://www.springframework.org/schema/jee
                           http://www.springframework.org/schema/jee/spring-jee-2.5.xsd"
                        >

    <bean id="propertyConfigurer"
          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
          p:location="/WEB-INF/jdbc.properties" />

    <context:annotation-config/>
    <context:component-scan base-package="tutorial.spring"/> 
    <tx:annotation-driven/> 

    <bean id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource"
          p:driverClassName="${jdbc.driver}"
          p:url="${jdbc.url}"
          p:username="${jdbc.username}"
          p:password="${jdbc.password}"
          />

    <bean id="sessionFactory"
          class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
          p:dataSource-ref="dataSource"
          p:configLocation="/WEB-INF/hibernate.cfg.xml"
          p:configurationClass="org.hibernate.cfg.AnnotationConfiguration"
          />

    <bean id="transactionManager"
          class="org.springframework.orm.hibernate3.HibernateTransactionManager"
          p:sessionFactory-ref="sessionFactory"
          />
   
</beans>

tutorial-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                           http://www.springframework.org/schema/aop
                           http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
                           http://www.springframework.org/schema/tx
                           http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
                           http://www.springframework.org/schema/context
                           http://www.springframework.org/schema/context/spring-context-2.5.xsd"
                           >
    
    <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
    <context:component-scan base-package="tutorial.spring.ui.springmvc" />
    <bean id="messageSource"
		class="org.springframework.context.support.ResourceBundleMessageSource"
		p:basename="messages" />

    <bean id="velocityConfig"
		class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
        <property name="resourceLoaderPath"
                 value="/WEB-INF/templates/velocity/"/>
    </bean>

    <bean id="viewResolver"
		class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
        <property name="cache" value="true" />
        <property name="prefix" value="/WEB-INF/templates/velocity" />
        <property name="suffix" value=".html" />
    </bean>

</beans>

UserDao.java

package tutorial.spring.dao;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Repository;
import tutorial.spring.base.dao.hibernate.BaseDaoHibernate;
import tutorial.spring.model.User;

@Repository
public class UserDao extends BaseDaoHibernate<User> {

    private static final Log LOG = LogFactory.getLog(UserDao.class);

    public List<User> getAllUser() {
        return sessionFactory.getCurrentSession().createQuery("from User ").list();
    }
}

MasterService.java

package tutorial.spring.service;
import java.util.Date;
import java.util.List;
import tutorial.spring.model.User;

/**
 *
 * @author user
 */
public interface MasterService {
    public void save(User user);
    public List<User> getAllUser();
 }

MasterServiceImpl.java

package tutorial.spring.service.impl;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tutorial.spring.dao.UserDao;
import tutorial.spring.model.User;
import tutorial.spring.service.MasterService;

/**
 *
 * @author user
 */
@Service("masterService")
@Transactional(readOnly = true)
public class MasterServiceImpl implements MasterService {

    @Autowired private UserDao userDao;

    @Transactional
    public void save(User user) {
        userDao.save(user);
    }

    public List<User> getAllUser() {
        return userDao.getAllUser();
    }

    /**
     * @param userDao the userDao to set
     */
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

   
}

UserController.java

package tutorial.spring.ui.springmvc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import tutorial.spring.dao.UserDao;
import tutorial.spring.service.MasterService;

@Controller
public class UserController {
	private UserDao userDao;
        private MasterService masterService;

     @Autowired
     public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

        @RequestMapping("/userlist")
	public ModelMap list(){
        System.out.println("User List");
	      return new ModelMap(masterService.getAllUser());
        }

    /**
     * @return the masterService
     */
    public MasterService getMasterService() {
        return masterService;
    }

    /**
     * @param masterService the masterService to set
     */
    public void setMasterService(MasterService masterService) {
        this.masterService = masterService;
    }

    /**
     * @return the userDao
     */
    public UserDao getUserDao() {
        return userDao;
    }

    
}

index.html

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>:: Spring 2.5 Tutorial ::</title>
</head>
<body>
<h1>Spring Tutorial</h1>

<ul>
	<li><a href="tutorial/userlist.html">List of user</a></li>
</ul>


</body>
</html>

i writen file userlist.hmtl in folder
WEB-INF
templates
velocity

userlist.html

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>:: List of All User ::</title>
</head>
<body>

<table border="0" cellpadding="2" cellspacing="2">
	<tr>
		<th>Name</th>
		<th>Email</th>
		<th>&nbsp;</th>
	</tr>
	#foreach($user in $userList)
	<tr>
		<td>$user.name</td>
		<td>$user.email</td>
		<td><a href="personform?person_id=$person.Id">edit</a> | <a
			href="persondetail?person_id=$person.Id">view</a></td>
	</tr>
	#end
</table>

</body>
</html>

when i run then clik link List Of User
got error:
INFO: 2010-12-24 13:34:44,638 [http-thread-pool-16492-(1)]
WARN org.springframework.web.servlet.PageNotFound No mapping for [/SpringFrameWrkMVCHiberVelocity/tutorial/userlist.html]
in DispatcherServlet with name 'tutorial'

thanks for you help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.