我几乎不知道如何使用 AJAX 和 jQuery,或者它是如何工作的,但我想使用 Struts 2 框架制作一个简单的登录 webapp。
我从网上得到了一个登录页面模板,如下所示:
<html>
<head>
  <link href="css/style.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
  <script type="text/javascript">
    $(document).ready(function() {
      $(".username").focus(function() {
          $(".user-icon").css("left","-48px");
      });
      $(".username").blur(function() {
          $(".user-icon").css("left","0px");
      });
      $(".password").focus(function() {
          $(".pass-icon").css("left","-48px");
      });
      $(".password").blur(function() {
          $(".pass-icon").css("left","0px");
      });
    });
  </script>
</head>
<body>
  <div id="wrapper">
    <div class="user-icon"></div>
    <div class="pass-icon"></div>
    <form name="login-form" class="login-form" action="" method="post">
      <div class="header">
        <h1>Login Form</h1>
        <span>
          Fill out the form below to login to my super awesome imaginary control panel.
        </span>
      </div>
      <div class="content">
        <input name="username" type="text" class="input username" value="Username" onfocus="this.value=''" />
        <input name="password" type="password" class="input password" value="Password" onfocus="this.value=''" />
      </div>
      <div class="footer">
        <input type="submit" name="submit" value="Login" class="button" />
        <input type="submit" name="submit" value="Register" class="register" />
      </div>
    </form>
  </div>
  <div class="gradient"></div>
</body>
</html>
为了使用该框架,我包含了 tag-libs 指令并将文件重命名为 .jsp 类型,然后将<form>标签更改为<s:form>and </s:form>。
之后,它会丢失模板的格式。我下载了 struts2-jquery 插件 jar 并尝试使用<sj: form>,但导致编译错误。
如何在不丢失模板格式和设计的情况下使用 struts 标签?
编辑:
http://imgur.com/GKV4b0P,51RmXhP
在这里您可以看到当我编辑<form>and</form>到<s:form>and</s:form>并添加 tag-lib 页面指令时会发生什么:
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
我还将扩展名更改为 .jsp 并没有编辑其他内容。