samedi 18 juin 2016

getting warning while running the spring mvc hello world program

i am getting warning while running spring hello world program like this

log4j:WARN No appenders could be found for logger (org.springframework.web.servlet.DispatcherServlet).

log4j:WARN Please initialize the log4j system properly.

here is my web.xml file

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
   <display-name>helloworldmvc</display-name>
   <servlet>
       <servlet-name>helloworld</servlet-name>
   <servlet-  class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
   </servlet>
   <servlet-mapping>
   <servlet-name>helloworld</servlet-name>
   <url-pattern>/</url-pattern>
   </servlet-mapping>
   </web-app>

and my helloworld-servlet.xml file

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

   <context:component-scan base-package="controller.HelloController1" />

 <bean   class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  <property name="prefix" value="/" />
  <property name="suffix" value=".jsp" />
  </bean>
  </beans>

and my HelloController1.java controller class

package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class HelloController1 {

@RequestMapping("/welcome")
public ModelAndView helloworld() {
    ModelAndView mav=new ModelAndView("hellopage");
    mav.addObject("msg","Hello world rizwan");
    return mav;
}

}

and my hellopage.jsp view page

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body> 
${msg }
</body>
 </html>  

everything is all right but some how this warning is refusing to run my application please help me.

enter image description here here a image for more convienence

Aucun commentaire:

Enregistrer un commentaire