Return-Path: X-Original-To: apmail-struts-user-archive@www.apache.org Delivered-To: apmail-struts-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A7A0C464D for ; Mon, 9 May 2011 06:14:02 +0000 (UTC) Received: (qmail 98006 invoked by uid 500); 9 May 2011 06:14:00 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 97980 invoked by uid 500); 9 May 2011 06:14:00 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 97968 invoked by uid 99); 9 May 2011 06:13:58 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 May 2011 06:13:58 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of thechrispratt@gmail.com designates 74.125.83.176 as permitted sender) Received: from [74.125.83.176] (HELO mail-pv0-f176.google.com) (74.125.83.176) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 May 2011 06:13:51 +0000 Received: by pve37 with SMTP id 37so3229315pve.35 for ; Sun, 08 May 2011 23:13:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=sLRk6wvHN6yzfrXENRZpKRxL9WRTJqL1HxHje0rc/AQ=; b=CLEPEePKIoRZp7VEDV3VreEjiP59bs11YNAe3AvUyuoGjOOpBzoZF9C7skIfVZ1hm0 rfXtGVvKgxx1BDwp0jyUx5qoIt70Wl+eaH5ByluDVaC2ES8EoTTq2JPY33zhVj6u/Cgd xF33mIOCLShQnQAPpfBya+7+00BhTtfEDGA7k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=Ys8hfK9tHLQTZYqrCSZSqmBPBvUr6AjF71L4KC1arh9RA1I5qZtW1Rj/tTnj5PGqCK 5/RoAPc3wJk81fOQ2mZsHjvBAadGLZYPsZGRMxGnE5kr4W2uaZJ/YdlEs0PqbQDRE+Pn SuW06UCaeqtyyT2SNGz/njAatoMfjqTK2gRVo= Received: by 10.68.69.39 with SMTP id b7mr4143844pbu.403.1304921610061; Sun, 08 May 2011 23:13:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.60.10 with HTTP; Sun, 8 May 2011 23:13:10 -0700 (PDT) In-Reply-To: <4DC706FB.5090709@marcusbond.co.uk> References: <4DC706FB.5090709@marcusbond.co.uk> From: Chris Pratt Date: Sun, 8 May 2011 23:13:10 -0700 Message-ID: Subject: Re: Strange behaviour with Spring To: Struts Users Mailing List Content-Type: multipart/alternative; boundary=0015176f186a0709f504a2d1bd7b X-Virus-Checked: Checked by ClamAV on apache.org --0015176f186a0709f504a2d1bd7b Content-Type: text/plain; charset=ISO-8859-1 You can't create beans that implement java.lang.String, it's immutable and doesn't follow the bean spec. (*Chris*) On Sun, May 8, 2011 at 2:11 PM, Marcus Bond wrote: > Hi, > > I'm using Struts 2.2.3 and have observed some bizarre behavior when using > Spring to provide my actions.. In order to simplify this and prove the > problem I have created a project with a single static html file, and a > single action in struts.xml which references a bean in my spring context > file. > > What basically happens is that if I declare a bean in my spring context > (bean unrelated toany struts action) that is of class java.lang.String (as I > do for a log4j filepath) then when I perform a redirect in an action mapping > this gets appended to the end of the url as the anchor. > > If I navigate to http://localhost:8080/My App/simpleRedirect > the result is a reirect to the 'simple' action but note the url struts has > redirected to: > > http://localhost:8080/MyApp/simple#this%20is%20a%20java.lang.String%20bean%20in%20my%20spring%20context > > For some reason the org.apache.struts2.dispatcher.ServletRedirectResult > class is being instantiated by with the anchor and location constructor args > set to the value of my spring bean by the StrutsSpringObjectFactory > > If I remove the String bean from the spring contect then the url behaves as > normal, redirecting to: > http://localhost:8080/MyApp/simple > > Have been scratching my head trying to find where this behaviour is > happening but have run out of time.. is this a known issue? > > Files content: > *Spring context file:* > > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:aop="http://www.springframework.org/schema/aop" > xmlns:tx="http://www.springframework.org/schema/tx" > xsi:schemaLocation="http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans-2.5.xsd > http://www.springframework.org/schema/tx > http://www.springframework.org/schema/tx/spring-tx-2.5.xsd > http://www.springframework.org/schema/aop > http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> > > > > > > > > > scope="prototype" /> > > > *Struts file:* > > "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" > "http://struts.apache.org/dtds/struts-2.0.dtd"> > > > > class="simpleAction"> > index.html > > > > > simple > > > > > *Java class uk.co.marcusbond.action.SimpleAction* > package uk.co.marcusbond.action; > > public class SimpleAction { > > public String execute() { > return "success"; > } > } > > > --0015176f186a0709f504a2d1bd7b--