angularjs - How to configure redirects Glassfish4 Maven Webapp -


i developing webapp using glassfish 4. have rest backend, developed in java using jersey, , angularjs frontend. contained in maven jersey-quickstart-webapp.

now, problem have when people query url app:

http://localhost:8080/myapp/ 

it works fine, , sends appropriate index.html user. however, if user types url 'should' handled apps routing, like:

http://localhost:8080/myapp/search 

it gives 404 error. however, url can reached within in app if start /myapp/ route, because index.html served angularjs stuff able understand , control routing.

essentially problem face need set appropriate redirects necessary places should return index.html.

so, when hit of following urls should send user index.html, , let angularjs figure out routing

eg.

http://localhost:8080/myapp/search   ----> index.html http://localhost:8080/myapp/results  ----> index.html http://localhost:8080/myapp/browse   ----> index.html 

unfortunately, being thick here, don't know how configure server/webapp this. how go doing this? assume obvious/trivial, i'm pretty new stuff, go easy on me!

edit 1: i've had using mod-rewrite or urlrewritefilter neither of these seems work glassfish4 far can see. there equivalent out there these might know of?

as @tunaki says, need use apache , use mod_rewrite. also, can use urlrewritefilter thats allows rewrite urls before code.

for that, need add maven file dependency:

<dependency>     <groupid>org.tuckey</groupid>     <artifactid>urlrewritefilter</artifactid>     <version>4.0.3</version> </dependency> 

and add in web-inf/web.xml file:

<filter>     <filter-name>urlrewritefilter</filter-name>     <filter-class>org.tuckey.web.filters.urlrewrite.urlrewritefilter</filter-class> </filter> <filter-mapping>     <filter-name>urlrewritefilter</filter-name>     <url-pattern>/*</url-pattern>     <dispatcher>request</dispatcher>     <dispatcher>forward</dispatcher> </filter-mapping> 

also, have big number of parameters specified in documentation: http://cdn.rawgit.com/paultuckey/urlrewritefilter/master/src/doc/manual/4.0/index.html#filterparams

http://localhost:8080/myapp/search   ----> search.html http://localhost:8080/myapp/results  ----> results.html http://localhost:8080/myapp/browse   ----> browse.html 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -