This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RequestMapping(value = "/upload", method = RequestMethod.POST, produces = MediaType.TEXT_HTML_VALUE) | |
| @ResponseBody | |
| public String upload(@RequestParam("file") MultipartFile file, String name, String message) throws Exception | |
| { | |
| Map<String, Object> resp = Maps.newHashMap(); | |
| FileCopyUtils.copy(file.getBytes(), new File('filename')); | |
| resp.put("success", true); | |
| resp.put("msg", "upload success."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RequestMapping(value = "/image/{id}", method = RequestMethod.GET) | |
| public void findImage(@PathVariable("id") String id, HttpServletResponse resp){ | |
| final Foto anafoto = <find object> | |
| resp.reset(); | |
| resp.setContentType(MediaType.IMAGE_JPEG_VALUE); | |
| resp.setContentLength(anafoto.getImage().length); | |
| final BufferedInputStream in = new BufferedInputStream(new ByteArrayInputStream(anafoto.getImageInBytes())); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.springframework.samples.mvc.fileupload; | |
| import java.io.IOException; | |
| import org.springframework.mvc.extensions.ajax.AjaxUtils; | |
| import org.springframework.stereotype.Controller; | |
| import org.springframework.ui.Model; | |
| import org.springframework.web.bind.annotation.ModelAttribute; | |
| import org.springframework.web.bind.annotation.RequestMapping; | |
| import org.springframework.web.bind.annotation.RequestMethod; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Controller | |
| @RequestMapping(value = "employees") | |
| public class EmployeeController { | |
| @Autowired | |
| CountryService countryService; | |
| @RequestMapping(value="/findActiveCitiesByCountry", method=RequestMethod.GET, | |
| headers = {"Accept=text/xml, application/json"}) | |
| @ResponseBody |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.IOException; | |
| import java.nio.file.*; | |
| import static java.nio.file.StandardWatchEventKinds.*; | |
| public class FileWatcher { | |
| private WatchService watchService; | |
| private void init() { | |
| Path path = Paths.get("/tmp/TARGET/"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.FileReader; | |
| import java.io.IOException; | |
| import java.io.BufferedReader; | |
| import java.util.*; | |
| import java.io.*; | |
| public class PHR { | |
| public static void main(String[] args) throws IOException { | |
| // monitor a single file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface GuavaCacheMXBean { | |
| public long getRequestCount(); | |
| public long getHitCount(); | |
| public double getHitRate(); | |
| public long getMissCount(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package package.name; | |
| import org.springframework.beans.factory.annotation.Autowired; | |
| import org.springframework.beans.factory.annotation.Value; | |
| import org.springframework.context.annotation.Bean; | |
| import org.springframework.context.annotation.Configuration; | |
| import org.springframework.core.env.Environment; | |
| import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; | |
| import org.springframework.security.config.annotation.web.builders.HttpSecurity; | |
| import org.springframework.security.config.annotation.web.builders.WebSecurity; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.asi.hrportal.security.*; | |
| import com.asi.hrportal.web.filter.CsrfCookieGeneratorFilter; | |
| import org.springframework.context.annotation.Bean; | |
| import org.springframework.context.annotation.Configuration; | |
| import org.springframework.core.env.Environment; | |
| import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; | |
| import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; | |
| import org.springframework.security.config.annotation.web.builders.HttpSecurity; | |
| import org.springframework.security.config.annotation.web.builders.WebSecurity; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package test; | |
| import java.security.Principal; | |
| import java.util.ArrayList; | |
| import java.util.HashMap; | |
| import java.util.List; | |
| import java.util.Map; | |
| import org.springframework.beans.factory.annotation.Autowired; | |
| import org.springframework.security.access.prepost.PreAuthorize; |