Created
July 28, 2011 14:17
-
-
Save franz-ka/1111623 to your computer and use it in GitHub Desktop.
First GAE + Spring MVC : Controllers
This file contains 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 com.gae.app; | |
// ... imports ... | |
@Controller | |
public class Controller1 { | |
@RequestMapping("/", method = RequestMethod.GET, params="miParam=miValor")) //solo si miParam esta | |
public void hello(@RequestParam("miValor") String unValor) {} | |
@RequestMapping("/articulos", method = RequestMethod.POST, headers="content-type=text/*") | |
@RequestMapping("/{usuario}") | |
@ResponseBody //devuelve HTML puro | |
public String getUsuario(@PathVariable String usuario, Model model) {} | |
} | |
@Controller | |
@RequestMapping("/articulos") | |
public class Controller2 { | |
@RequestMapping(value="/{id}") //mapea ../articulos/5, ../articulos/45, etc. | |
public void getArticulo(@PathVariable Long id, Model model) {} | |
@RequestMapping(value="/proovedores/{provId}/franquisias/{franId}") | |
public void getFranquisia(@PathVariable long provId, @PathVariable long franId, Model model) {} | |
} | |
@Controller | |
@RequestMapping("/personas/{persona}") | |
public class Controller3 { | |
@RequestMapping(value = "/mascotas/{mascotaId}" | |
public void getMascota(@PathVariable String persona, @PathVariable long mascotaId, Model model) {} | |
} |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:p="http://www.springframework.org/schema/p" | |
xmlns:context="http://www.springframework.org/schema/context" | |
xsi:schemaLocation=" | |
http://www.springframework.org/schema/beans | |
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd | |
http://www.springframework.org/schema/context | |
http://www.springframework.org/schema/context/spring-context-3.0.xsd"> | |
<context:component-scan base-package="com.gae.app"/> | |
// ... | |
</beans |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment