Package org.springframework.web.servlet.mvc

Examples of org.springframework.web.servlet.mvc.Controller


    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
        String path = request.getServletPath();
        String internalPath = path.replaceAll(xmlMarker, "");

        Controller controller = (Controller) getApplicationContext().getBean(internalPath);
        if (controller != null) {
                ModelAndView modelAndView = controller.handleRequest(request, response);
                if (modelAndView.getModel() != null) {
                    TransportableModel tm = new TransportableModel();
                    tm.putAll(modelAndView.getModel());
                    XStream x = new XStream();
                    x.toXML(tm, response.getWriter());
View Full Code Here


    parameterSeparator = "_";
    nameValueSeparator = "-";
    setAdapterProperties();
   
    HttpServletRequest request = new MockHttpServletRequest(GET, "/foo~a-1_b-2.html");
    adapter.handle(request, new MockHttpServletResponse(), new Controller() {

      public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        assertEquals("a is not 1", "1", request.getParameter("a"));
        assertEquals("b is not 2", "2", request.getParameter("b"));
        assertEquals("not two parameters", 2, request.getParameterMap().size());
View Full Code Here

    parameterSeparator = ".am.";
    nameValueSeparator = ".eq.";
    setAdapterProperties();
   
    HttpServletRequest request = new MockHttpServletRequest(GET, "/foo.qm.a.eq.1.am.b.eq.2.html");
    adapter.handle(request, new MockHttpServletResponse(), new Controller() {

      public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        assertEquals("a is not 1", "1", request.getParameter("a"));
        assertEquals("b is not 2", "2", request.getParameter("b"));
        assertEquals("not two parameters", 2, request.getParameterMap().size());
View Full Code Here

   */
  public void testOtherSuffix() throws Exception {
    setAdapterProperties();
   
    HttpServletRequest request = new MockHttpServletRequest(GET, "/foo~a-1_b-2.gif");
    adapter.handle(request, new MockHttpServletResponse(), new Controller() {

      public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        assertEquals("The uri should be /foo~a-1_b-2.gif", "/foo~a-1_b-2.gif", request.getRequestURI());
        assertEquals("there are parameters", 0, request.getParameterMap().size());
        return null;
View Full Code Here

   */
  public void testMultipleValues() throws Exception {
    setAdapterProperties();
   
    HttpServletRequest request = new MockHttpServletRequest(GET, "/foo~a-1_a-2_b-3.html");
    adapter.handle(request, new MockHttpServletResponse(), new Controller() {

      public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        String[] values = request.getParameterValues("a");
        assertEquals("Should have two values", 2, values.length);
        // there is no guarantee that the values will be in order; we must sort the names
View Full Code Here

  /**
   * Verify that if the {@link #controller} is a proxy, but isn't a {@link BaseCommandController}
   *  it still works correctly (o.e. no-op).
   */
  public void testHappyCaseWithProxiedPlainController() throws Exception {
    Controller plainController = new PlainController();
    ProxyFactory factory = new ProxyFactory(plainController);
    Object proxiedController = factory.getProxy();
   
    this.interceptor.postHandle(this.request, this.response, proxiedController, this.modelAndView);
   
View Full Code Here

  /**
   * Verify that the handler works correctly (i.e. is a no-op) when the {@link #controller}
   * isn't a {@link org.springframework.web.servlet.mvc.BaseCommandController}.
   */
  public void testWhenHandlerIsntBaseCommandController() throws Exception {
    Controller plainController = new PlainController();
    this.interceptor.postHandle(this.request, this.response, plainController, this.modelAndView);
   
    Map map = this.modelAndView.getModel();
    assertFalse("expected non BaseCommandControllers to be ignored", map.containsKey("ValangRules.command"));
  }
View Full Code Here

    return transformerFactory;
  }
 
  public HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {

    Controller controller = new InspectRequestManager().lookupController(request, getTransformerFactory());

    if (controller == null)
      return null;
   
    return new HandlerExecutionChain(controller);
View Full Code Here

TOP

Related Classes of org.springframework.web.servlet.mvc.Controller

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.