خرید بک لینک

Vote count: 0

Full controller:

@Controller
@RequestMapping("/post")
public class PostController {
  @Autowired
  PostService postService;
  @ResponseBody
  @ResponseStatus(HttpStatus.OK)
  @RequestMapping(method = RequestMethod.GET)
  public String getPost(){
    Post post = postService.getPost();
    retu "post";
  }
}

@RequestMapping("post") or @RequestMapping("/") didn't work either

WebAppInitializer (as web.xml config)

public class WebAppInitializer extends AbstractAotationConfigDispatcherServletInitializer {
  @Override
  protected Class<?>[] getRootConfigClasses() {
    retu new Class<?>[]{RootContextConfig.class, DevelopmentConfiguration.class};
  }
  @Override
  protected Class<?>[] getServletConfigClasses() {
    retu new Class<?>[]{ServletContextConfig.class};
  }
  @Override
  protected String[] getServletMappings() {
    retu new String[]{"/"};
  }
}

Servlet Config:

@Configuration
@EnableWebMvc
@ComponentScan("blog.controllers")
public class ServletContextConfig extends WebMvcConfigurerAdapter {
  @Override
  public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/").addResourceLocations("/");
  }
}

The html files in the resources folder work fine, this is the actual web.xml

<!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>Archetype Created Web Application</display-name>
    <welcome-file-list>
        <welcome-file>/resources/index.html</welcome-file>
    </welcome-file-list>
</web-app>

I'm trying to at least see a 500 server error, but it keeps showing 404 when trying to access example.com/post, although the static resources in the resources folder are served fine by tomcat7, is there anything else I can try?

asked 3 mins ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 9 خرداد 1395 ساعت: 4:51

صفحه بندی