随手写的小博客,为了实现下面的表单
1.index.jsp
为了初始化表单,可以通过一个超链接
<a href="redirect/user_login">点击登录</a>
2.控制器:redirect/user_login
@Controller
@RequestMapping(path = "/redirect")
public class RedirectController {
@RequestMapping(path = "/user_login")
public ModelAndView user_login()
{
String str="0123456789qawsedrftgyhujikolpmnbvcxz";
String number="";
Random r=new Random();
for(int i=0;i<4;i++)
{
number+=str.charAt(r.nextInt(str.length()));
}
ModelAndView mv=new ModelAndView();
mv.addObject("number",number);
mv.setViewName("/pages2/user_login");
return mv;
}
}
3.jsp:pages2/user_login
<form action="../account/user_login" method="post">
<table>
<tr>
<td>anumber<input type="text" name="anumber" ><span id="anumber_msg"></span>