ssm框架ajax跳转到新页面进行传值

贼皮滴小仙女 贼皮滴小仙女 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我没进入ajax里面去 但是点击事件是有效的 这是怎么回事呀 有什么问题吗
我的页面主要内容
<tr>
<td class="namestyle">标题:</td>
<td><input type="text" name="title" class="input input-sm"
value="${n.title}">
</td>
</tr>
<tr>
<td class="namestyle">简介:</td>
<td><textarea class="input input-sm" placeholder="内容"
name="introduction" id="introduction"
style="overflow:hidden; resize:none;width:300px;height:130px;"
required pattern="/^\s*$/g" title="不能为空哦">${n.introduction}</textarea>
</td>
</tr><tr>
<td class="namestyle">详情:</td>
<td><textarea id="productEditor" name="content"
style="width: 100%;"></textarea>
<script type="text/javascript">
UE.getEditor('productEditor');
</script>
</td>
</tr><button type="button" id="yulan" class="btn btn-danger">跳转</button>



我的ajax
$("#yulan").click(function() {
var title =$("input[name='title']").val();
var content =$("textarea[name='content']").val();
var introduction =$("textarea[name='introduction']").val();
$.ajax({
url : "/PreviewNews", //后台url
data : { //数据
title : title,
content :content,
introduction : introduction
},
type : "POST", //类型,POST或者GET
dataType : "json", //数据返回类型,可以是xml、json等
success : function(data) { //成功,回调函数
alter("234d");
if (data == null) {
alert("没有这个用户!");
} else {
window.location.href = "/PreviewNews";
}
}
});
});
我的controller

@Controller
public class PreviewController {

@ResponseBody
@RequestMapping(value = "/PreviewNews")
public String PreviewNews(String title, String content,HttpServletRequest request, String introduction) {
System.out.println(title);
request.setAttribute("introduction", introduction);
request.setAttribute("title", title);
request.setAttribute("content", content);
return "PreviewNews";
}
}
...全文
评论 77
收藏 已收藏
分享
返回顶部
贼皮滴小仙女
Web 开发 81,107 成员 341,720 内容