我正在创建一个基本的Hello World程序。我编码的所有内容似乎都是正确的,但程序无效。
Servlet web.xml是:
<servlet>
<servlet-name>MyDispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>MyDispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Dispatcher Servlet是:
<context:component-scan base-package="com.controller" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/JSP/" />
<property name="suffix" value=".jsp" />
</bean>
调用callingDate.html:
<body>
<p>
<a href="showdate.html">click here to get DATE TIME.</a>
</p>
</body>
调用了shows.jsp:
<body>
today date time string is :
<span>${date}</span>
</body>
控制器类:
package com.controller;
import java.util.Date;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping("/showdate")
public class DateShowController {
@RequestMapping(method = RequestMethod.GET)
public String showmethod(ModelMap model) {
model.addAttribute("date", new Date());
return "showing";
}
}
类层次结构为:
答案 0 :(得分:1)
尝试删除.html
<a href="showdate.html">