• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring

 
kate pal
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All ,

I am trying very basic spring application
below is the xml files

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>


<bean name="/home.htm" class="com.test.controller.testController">
<property name="greeting">
<value>Welcome to Spring Training!</value>
</property>
</bean>

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>

</beans>
this is training-servlet.xml

and below is web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<display-name>springMvc</display-name>

<servlet>
<servlet-name>training</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>training</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>



</web-app>

-----------------------------
testController.java

package com.test.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

public class testController implements Controller{

public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
return new ModelAndView("home", "message", greeting);
}
private String greeting;
public void setGreeting(String greeting) {
this.greeting = greeting;
}
}
-------------------------------------------------

home.jsp
<%@ 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>
<% out.println(" ==> home" ); %>
</body>
</html>

I kept all neccessary .jar in my classpath

when I deploy this application I got
HTTP Status 404 - /springMvc/home.htm

--------------------------------------------------------------------------------

type Status report

message /springMvc/home.htm

description The requested resource (/springMvc/home.htm) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/5.5.26
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked at any of the Tomcat logs to see what, if anything, is going wrong? and what is the directory structure of your web app and where, exactly is it located on your machine?
and also check into your tomcat manager to check the status of your application.
[ October 11, 2008: Message edited by: Muhammad Saifuddin ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the servlet mapping in your web.xml. Maybe it just needs a "/" in from of the URL mapping. That is where I always make my mistakes.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic