java表单提交标签_java – 为什么表单提交会打开新窗口/标签?

我发现了很多问题

“How to open form result in new window”,但我面临着相反的问题.

我有形式:

...

然后我有控制器与处理方法

@RequestMapping(value = "/search.form", method = RequestMethod.POST)

public String submit( @Valid final SearchObject searchObject, final BindingResult bindingResult ) {

if ( bindingResult.hasErrors() ) return "forms/search";

return "redirect:/A/result.form";

}

一切正常,除了在新窗口/选项卡中打开结果的事实.

我找到并正在运行的解决方案是添加目标属性:

但是_self是默认的AFAIK.

我想知道为什么会这样.

我检查生成的HTML,在我看来好吧:

编辑添加的标题

Content-Language en-US

Content-Length 0

Date Thu, 22 Mar 2012 16:29:13 GMT

Location http://localhost:8080/myApp/A/result.form

Server Apache-Coyote/1.1

Request Headersview source

Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/ *;q=0.8

Accept-Encoding gzip, deflate

Accept-Language en-us,en;q=0.5

Connection keep-alive

Cookie JSESSIONID=E9ACB44C4ED3814814ABE7D96C90135C; GUEST_LANGUAGE_ID=cs_CZ; COOKIE_SUPPORT=true

Host localhost:8080

Referer http://localhost:8080/myApp/A/search.form

User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0

Response Headers From Cache

Content-Language en-US

Content-Length 0

Date Thu, 22 Mar 2012 16:29:13 GMT

Location http://localhost:8080/myApp/A/result.form

Server Apache-Coyote/1.1

Request Headers From Upload Stream

Content-Length 64

Content-Type application/x-www-form-urlencoded

GET sessions.form

200 OK

localhost:8080

309 B

::1:8080

6ms

HeadersResponseCacheHTML

Content-Language en-US

Content-Length 309

Content-Type text/html;charset=utf-8

Date Thu, 22 Mar 2012 16:29:13 GMT

Server Apache-Coyote/1.1

Request Headersview source

Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/ *;q=0.8

Accept-Encoding gzip, deflate

Accept-Language en-us,en;q=0.5

Connection keep-alive

Cookie JSESSIONID=E9ACB44C4ED3814814ABE7D96C90135C; GUEST_LANGUAGE_ID=cs_CZ; COOKIE_SUPPORT=true

Host localhost:8080

Referer http://localhost:8080/myApp/A/search.form

User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0

编辑2为result.form添加的方法

@RequestMapping(value = "/result.form", method = RequestMethod.GET)

public String result() {

return "forms/result";

}

我的控制器类以:

@Controller

@RequestMapping(value = "/A")

public class AController {

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值