adasdasd adasdasd - 2 months ago 20x
AngularJS Question

Angular JS , Tomcat Apache , # Urls

I think i am dreaming in my worst nightmare with tomcat apache.

What i want

In angularJs there is # problem like

to make this correct i read a lot, and i found that


can solve this and it solved my problem but after refresh the same link it says
404 not found
again i read a lots of stuff about it and i found it can be solve through ".htaccess"

Now i was like WTF.

Because tomcat apache cant use or process ".htaccess" files, already i have gone through this and i know it.

Now i am really cluess what to do with AngularJS in Tomcat apache,
is there any GOD/experieced/a good person/programmer who can help me?

is there anyone who have faced the same problem and used AngularJs with Tomcat Apache? and solved the # problem? (to be specific - i am using tomcat apache because my backed code is in Spring MVC)


From starting and step to step so solve this head hammer problem

Activate HTML 5 Mode

Open the app.js file and add this line in config method:

$locationProvider.html5Mode({ enabled: true, requireBase: true });

Then open index.html and add this line in head tag:

<base href="/">

Note in base href you should give your root folder otherwise it will always be redirected to localhost:/ (ex <base href="/cms/"> )

in your case i beleive you have done the both but you are getting the snappy 404

But here is the main solution

in Restcontroller try this

  @RequestMapping(value = "/{[path:[^\\.]*}")
    public String redirect() {
        return "forward:/";

Reference :