简体   繁体   中英

404 Error when reload page in a Tomcat web application

I've deployed a Java web application using spark-java and angularJS (ui-router) on a Tomcat9 web server. When I try to reload the page, tomcat will launch an HTTP Status 404 . This happens with all the views except for the main route '/'. Tomcat is mapped on port 80, started by root user, and the app has been deployed on webapps/ROOT folder. I don't really know what to do.

I also use html5mode in app.js:

app.config(["$locationProvider", function($locationProvider) { 
     $locationProvider.html5Mode(true); 
}]);

and added <base href="/"> in index.html <head>

UPDATE:

In my server.xml I added the following code:

<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
    <Valve className="org.apache.catalina.valves.rewrite.RewriteValve"/>
</Host>

and in /conf/Catalina/localhost/rewrite.config:

RewriteRule ^/(.*) index.html [L]

And now i've this console error for all the imported scripts:

Uncaught SyntaxError: Unexpected token <

It looks like it replaces all the scripts with index.html text.

Have you properly included the filter in web.XML according to the 'Other Web server' section in spark java documentation. ?

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