在Java中,我可以编写一个非常基本的JSP,index.jsp
如下所示:
<% request.getRequestDispatcher("/home.action").forward(request, response); %>
这样做的效果是,用户请求index.jsp
(或者仅包含目录假设index.jsp
是目录的默认文档)将在home.action
没有浏览器重定向的情况下看到,即[forward]
我可以做类似于PHP的东西吗?
发布于 2018-06-14 17:03:29
如果使用像Zend Framework提供的MVC,则可以更改控制器操作,甚至可以在控制器操作之间跳转。
发布于 2018-06-14 17:45:20
如果你担心cURL可用性,那么你可以使用file_get_contents()
。设置如下功能:
function forward($location, $vars = array())
{
$file ='http://'.$_SERVER['HTTP_HOST']
.substr($_SERVER['REQUEST_URI'],0,strrpos($_SERVER['REQUEST_URI'], '/')+1)
.$location;
if(!empty($vars))
{
$file .="?".http_build_query($vars);
}
$response = file_get_contents($file);
echo $response;
}
https://stackoverflow.com/questions/-100000283
复制相似问题