0

I have a javascript and images that would be simpler to access via the RESOURCES servlet.

But I cant find any "how to" or example documentation - can someone point me to that?


My apologies to those who responded - non of the answers seem to have anything to do with my question, so my question must be very badly written. I will try again

In my current jsp I have

dojo.require("dojo.parser"); dojo.require("dijit.layout.ContentPane"); dojo.require("dijit.layout.TabContainer"); dojo.require("dijit.layout.AccordionContainer");

and this is working - I understand it is getting the Dojo js from org.springframework.js-2.3.0.RELEASE.jar?

and this is enabled by the

<servlet>
    <description>generated-resources-servlet</description>
    <servlet-name>Resource Servlet</servlet-name>
    <servlet-class>
        org.springframework.js.resource.ResourceServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Resource Servlet</servlet-name>
    <url-pattern>/resources/*</url-pattern>
</servlet-mapping>

in web.xml

Now I want to use a dojox chart, which requires

dojo.require("dojox.charting.widget.Chart2D"); dojo.require("dojox.charting.themes.Claro");

and these are not being found.

So I want to learn how to manage set up and access of things like .js and images as is done for
, e.g. Spring.js

I have seen the documentation at http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-static-resources but would really like to see some examples.

Hope this makes sense.

Ribeye
  • 2,137
  • 3
  • 18
  • 25
  • did you have a look at this? http://static.springsource.org/spring-webflow/docs/current/reference/html/ch12s02.html – Abdel Raoof Olakara Mar 07 '12 at 07:43
  • Does nickdos's answer help you ?http://stackoverflow.com/questions/1483063/spring-mvc-3-and-handling-static-content-am-i-missing-something – S.P. Mar 07 '12 at 07:45

3 Answers3

1

I am sending you code snippet for apache httpClient library to upload a file from client to server using spring mvc.

    HttpClient client = new DefaultHttpClient();
    HttpPost httpPost = new HttpPost(uri);

    MultipartEntity mpEntity = new MultipartEntity(
            HttpMultipartMode.BROWSER_COMPATIBLE);
    FileBody contentBody = new FileBody(YOUR_FILE_OBJECT, file.getContentType());
    mpEntity.addPart("file", contentBody);
    httpPost.setEntity(mpEntity);
    HttpResponse httpResponse = null;
    try {
        httpResponse = client.execute(httpPost);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

=> please download httpClient.jar and other jar files from apache site.

kundan bora
  • 3,821
  • 2
  • 20
  • 29
0

You can find those dojo elements in or.springframework.js.resources-2.x.x jar file.i

Mihai Iorga
  • 39,330
  • 16
  • 106
  • 107
Praveen
  • 41
  • 1
  • 6
0

I am not sure what you are asking for. If you want to send some resource like binary file(example- images) from client to server using Spring MVC (REST services) then you can use RestTemplate of spring. You can also use MultipartEntity from Apache HttpClient library.

Some useful links are ->

http://blog.springsource.org/2009/03/27/rest-in-spring-3-resttemplate/

if you want to use apache HttpClient library- http://hc.apache.org/httpclient-3.x/methods/multipartpost.html

kundan bora
  • 3,821
  • 2
  • 20
  • 29