سلام .
من یه پرژه ساده دارم که به ازای رفتن به ادرس greeting.html کنترلر یه پیغامی رو نشون میده .
ولی نمیدونم چرا اجرا نمیشه ؟ ! به نظرم مشکلش dispatcherservlet not found باشه ... فایلهارو پائین میزارم
درضمن از maven استفاده نکردم ...
web.xml :
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>FitnessTracking</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>greeting.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>fit</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/servlet-config.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>fit</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
</web-app>
servlet-config.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:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schem...ng-mvc-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schem...ring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="com.amir.controller"></context:component-scan>
<!-- <bean class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix"
value=".jsp" /> </bean> -->
<bean
class="org.springframework.web.servlet.view.Intern alResourceViewResolver"
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />
</beans>
helloController.java :
package com.amir.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMap ping;
@Controller
public class helloController {
@RequestMapping(value = "/greeting")
public String sayHello(Model model) {
model.addAttribute("greeting", "hello world !");
return "hello !";
}
}
<%@ page language="java" contentType="text/html; charset=windows-1256" pageEncoding="windows-1256"%>
<!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=windows-1256">
<title>Insert title here</title>
</head>
<body>
<h1>${greeting}</h1>
</body>
</html>
کلا این چندمین پروزه ای هست که نمیتونم اجراش کنم ؟! چندین بار نسخه spring و اکلیپس رو تغییر دادم و سرور جدید ساختم ولی باز هم نشد .
حالا دقیق نمیدونم مشکل من کجاست ؟ تو کد هست یا مثلا تو کتابخونه و ... ؟درضمن تو build path کتابخانه های Spring 4 + common log هم موجوده .
اینم خود پروژه