java - How to edit file in resources of Spring MVC? -
i have project on spring mvc, resources folder added buildpath of spring.
on ui action want edit file resources/thirdparty/thirdparty.er controller.
so here code tried
file inputfile = new file("/home/local/<user>/desktop/workspace/<projectname>/webcontent/resources/thirdparty/thirdparty.er");
result - worked fine
instead of absolute path wanted relative path tried
file inputfile = new file("../../<something>/webcontent/resources/thirdparty/thirdparty.er");
result - worked fine, path relative eclipse(base path), executing code in eclipse
to remove eclipse path dependency, tried
file inputfile = new file("/resources/thirdparty/thirdparty.er");
result - didnot worked
later on searching web, found
resource resource = new classpathresource("/thirdparty/thirdparty.er"); file inputfile = resource.getfile();
result - returning
/home/local//desktop/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps//web-inf/classes/thirdparty/thirdparty.er
which isn't file want edit. please let me know how can done. donot want path dependencies on eclipse, server or system, sould based on project.
maybe need is
resource resource = resourceloader.getresource("classpath:/thirdparty/thirdparty.er");
and autowire resource loader that:
@autowired private resourceloader resourceloader;
Comments
Post a Comment