我目前在顶部使用工具栏,并希望用主页按钮替换默认的后退按钮.但是当我添加项目时,它总是添加到右边.我没有看到任何layout_gravity选项可供选择.有没有办法做到这一点?
主要活动
Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_delete);
toolbar = (Toolbar)findViewById(R.id.app_bar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(" Testing");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.home_icon_empty, menu);
return true;
}
Run Code Online (Sandbox Code Playgroud)
home_icon_empty.xml
<item
android:id="@+id/homepage"
android:orderInCategory="100"
android:title="HOME"
android:icon="@drawable/home_icon"
app:showAsAction="always"
/>
<item
android:id="@+id/homepage1"
android:orderInCategory="200"
android:title="HOME"
android:icon="@drawable/home_icon"
app:showAsAction="always"
/>
Run Code Online (Sandbox Code Playgroud)
activity_main.xml中
<include
android:id="@+id/app_bar"
layout="@layout/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
Run Code Online (Sandbox Code Playgroud)
app_bar.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary">
</android.support.v7.widget.Toolbar>
Run Code Online (Sandbox Code Playgroud)
当前工具栏输出:
预期的工具栏输出: …
我试图运行我的jsp页面和servlet.当我尝试通过url调用它时找不到Servlet
http:// localhost:8080/StudentServlet 我收到404错误说:
"请求的资源不可用".
我也试图通过表格来调用它.当我单击提交时,无法识别它产生相同的错误.
在这里阅读答案,要求使用Maven或通过web.xml设置映射.根据我的理解,通过web.xml设置是旧方法,新方法是在我拥有的servlet上设置名称.不确定我做错了什么.
我没有使用和构建工具,只是启动我在本地使用的Tomcat服务器来运行jsp页面.但Servlet无法识别.添加了项目结构的截图,以防出现问题.
Servlet的
@WebServlet(name = "StudentServlet")
public class StudentServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><body>");
out.println("<h3>Student name is:" +
request.getParameter("firstname") +
" " +
request.getParameter("lastname") +
"</h3>");
out.println("</body></html>");
}
}
Run Code Online (Sandbox Code Playgroud)
的index.jsp
<form action="StudentServlet" method="get">
First Name: <input type="text" name="firstname"/>
<br/><br/>
Last Name: <input type="text" name="lastname"/>
<br/><br/>
<input type="submit" value="Submit"/>
</form> …Run Code Online (Sandbox Code Playgroud) 我有一个主批处理文件,它调用多个批处理文件。我希望能够同时执行所有这些批处理文件。完成所有操作后,我需要在主匹配文件中进行进一步的处理。
当我使用“开始”调用多个批处理文件时,能够同时启动所有批处理文件,但是我无法跟踪它们。(主批处理文件认为它们的过程在执行其他批处理文件的那一刻就完成了)。
当我使用“呼叫”时,能够监视批处理文件的过程,但是它将按顺序而不是同时启动批处理文件。
有没有解决的办法?在此PC上具有有限的权限,并尝试仅使用批处理来完成此操作。
主批处理文件
call first.bat
call second.bat
call third.bat
:: echo only after all batch process done
echo done!
Run Code Online (Sandbox Code Playgroud)
蝙蝠
timeout /t 10
Run Code Online (Sandbox Code Playgroud)
蝙蝠
timeout /t 10
Run Code Online (Sandbox Code Playgroud)
蝙蝠
timeout /t 10
Run Code Online (Sandbox Code Playgroud)