简体   繁体   中英

Changes not shown after commit (Heroku Java)

I am working on a Java project on Spring framework. The project is cloned from the Heroku site. I encountered two issues...

  1. I have created a JSP file (testing.jsp) and committed + pushed to Heroku. I created it in src/main/webapp/WEB-INF/jsp/testing.jsp

     <servlet-name>spring</servlet-name> <url-pattern>/people/*</url-pattern> <url-pattern>/testing/*</url-pattern> 

    I have edited it in web.xml file and pushed to Heroku. However, when I tried to view it in my browser, it shows me the same interface as the default people.jsp page.

My web.xml file: https://skydrive.live.com/redir?resid=2FC5994FBEB75CC5!174&authkey=!APyQGWZbKhkoAyM

  1. I have created a css file and pushed to Heroku. I have added the following...

    <link href="/imageCSS.css" rel="stylesheet">

    When I view in browser, it shows "HTTP Status 404 - /imageCSS.css"

    I am new to this and I can't seem to google anything useful that helps me in my issue.

You need to:

  1. Add the mvc:resources config in your applicationContext.xml like following:

     <mvc:resources mapping="/resources/**" location="/resources/" /> 
  2. Create a folder css under src/main/webapp/resources/ , even the resources one if you haven't it.

  3. Link the ccs stylesheet in your jsp as following:

    <link rel="stylesheet" href="<c:url value="/resources/css/imageCSS.css" />">

  4. Remember to include also the JSTL taglig in your page:

    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

For the point 1, you can't add multiple <url-pattern> to a single <servlet-mapping> . You should have something like this:

<servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>/people/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>/testing/*</url-pattern>
</servlet-mapping>

I managed to solve my first issue. I don't really know where the exact problem lies on but I believe it is either I didn't map the request correctly in my controller class initially or I didn't implement out the methods and model class for that controller in order for everything to function properly.

Thanks for all the helps, really appreciate.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM