静态的弹簧映射未映射

时间:2018-10-18 22:44:06

标签: java spring

我在WebContent html文件夹下有htmls

我在下面有静态内容的映射,并且我收到了此消息。 你能检查一下并告诉我这里有什么问题吗

org.springframework.web.servlet.PageNotFound noHandlerFound 警告:在DispatcherServlet中,名称为“ springController”的URI [/ LoginApp / html / 404ErrorPage]的HTTP请求未找到映射

 <bean id="staticPagesViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/"/>
    <property name="suffix" value=".htm"/>
    </bean>

package com.wachoviasec.login.servlet;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class ErrorController {

  @RequestMapping(value = "errors", method = {RequestMethod.GET,RequestMethod.POST})
  public String renderErrorPage(HttpServletRequest httpRequest) {

    String errorPage = null; 
    int httpErrorCode = getErrorCode(httpRequest);

    switch (httpErrorCode) {
      case 301: {
        errorPage = "/html/301ErrorPage.htm";
        break;
      }
      case 403: {
        errorPage = "/html/403ErrorPage.htm";
        break;
      }
      case 404: {
        errorPage = "/html/404ErrorPage";
               break;
      }
      case 500: {
        errorPage = "/html/500ErrorPage.htm";
        break;
      }
      case 503: {
        errorPage = "/html/503ErrorPage.htm";
        break;
      }
    }
    return errorPage;
  //  return "redirect:"+errorPage;
 //   return "forward:"+errorPage;
  }

  private int getErrorCode(HttpServletRequest httpRequest) {
    return (Integer) httpRequest.getAttribute("javax.servlet.error.status_code");
  }
}

1 个答案:

答案 0 :(得分:0)

您在404错误代码中缺少.htm:3