Error when trying to execute action class after hosting a java website made in struts2

谁说我不能喝 提交于 2020-01-05 23:28:14

问题


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.

  1. Fix your code such that is works for root context (/) locally i.e. http://localhost:8280/foryou/searchonbb.action will become http://localhost:8280/searchonbb.action

  2. Upload on server with name ROOT.war (case is important)

  3. If there is existing ROOT.war on server, simply stop tomcat and rename it and then upload your ROOT.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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!