问题
I have made a website in java struts2 and i have hosted it.
Its running well but what happens is whenever i try to execute any action it gives error of 404 . when i run on any local server through eclipse everything is fine ,no error and no exceptions but after hosting it gives this error.
when i run on local host its URL is ёhttp://localhost:8280/foryou/searchonbb.actionё and everything works perfectly.
and when i try to execute same action online its shows URL something like this http://info4blood.in/foryou/foryou/BloodBankSection.jsp#login and error image is attached . what i found is when i deployed app in Cpanel all java classes are placed in WEB-INF folder with .class files as well. So is this the problem ?? But i am able to login in to an account and after login into any account and when try to execute some action i face problem.
Note: while uploading my web app i set contextpath to "foryou".
Anybody please help . Thanks in advance :)
回答1:
From what I can understand, it's a context problem.
Fix your code such that is works for root context (
/
) locally i.e.http://localhost:8280/foryou/searchonbb.action
will becomehttp://localhost:8280/searchonbb.action
Upload on server with name
ROOT.war
(case is important)If there is existing
ROOT.war
on server, simply stop tomcat and rename it and then upload yourROOT.war
回答2:
This worked for me :
In eclipse (right click on my project) under properties > web project settings > set context path to "/" and now make WAR file of your project .
Upload project in NGASI panel (hosting panel provided by webhosting providers) and deploy your project and after deploying (it will ask you to set context path) set context path in ngasi panel to "foryou" which is my project name and deployed it .and it worked perfectly !
来源:https://stackoverflow.com/questions/32167955/error-when-trying-to-execute-action-class-after-hosting-a-java-website-made-in-s