当前位置: 代码迷 >> Java Web开发 >> 这么简单的代码怎么用struts 实现mvc呢?
  详细解决方案

这么简单的代码怎么用struts 实现mvc呢?

热度:6   发布时间:2016-04-17 15:28:04.0
这么简单的代码如何用struts 实现mvc呢??????
有两个页一个是index.jsp一个是get.jsp,index.jsp页里有两个textbox   当在第一个文本框中输入完值,焦点离开时触发javascript,弹出get.jsp页,并在get.jsp接收index.jsp中的文本框内容,现在是可以实现了,但是代码和页面写在了一起,我想用struts给分离开,请问该怎么做呢,??
index.jsp页源码:
<%@page   contentType= "text/html;   charset=GB2312 "   %>
<html>
<head>

<title> Insert   title   here </title>
</head>
<body>
 
参数: <input   type= "text "   onblur= "javascript:window.open( 'get.jsp?id=454 ') ">
<input   type= "text ">
 
</body>
</html>
get.jsp源码
<%@page   contentType= "text/html;   charset=GB2312 "   %>
 
<html>
<head>

<title> Insert   title   here </title>
</head>
<body>
<%
out.println(request.getParameter( "id "));
  %>
</body>
</html>
主要是想让get.jsp页里不写 <%
out.println(request.getParameter( "id "));
  %>


------解决方案--------------------
用struts后,还是要求当焦点离开textbox1时打开get.jsp页面吗,
添加一个提交按钮可以吗
------解决方案--------------------
1.写一个action,在action里面取得从index.jsp传入的id参数的值,并把id放到request里面
2. <input type= "text " onblur= "javascript:window.open( 'get.jsp?id=454 ') "> 改成提交action
3.在action里面返回到get.jsp.取得从action中放入request的id值
  相关解决方案